Python的:制作一个消音 [英] Python: Making a beep noise

查看:285
本文介绍了Python的:制作一个消音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让该计划给我一个蜂鸣声。我是在Windows机器上。我看了<一个href=\"http://docs.python.org/library/winsound.html\">http://docs.python.org/library/winsound.html

I'm trying to get the program to give me a beeping noise. I'm on a windows machine. I've looked at http://docs.python.org/library/winsound.html

但不知道如何可以与一个酒吧code扫描程序这一点。

But not sure how I can program this with a barcode scanner.

下面是我的code串行栏code扫描仪。

Here is my code for the serial barcode scanner.

ser = serial.Serial()
ser.baudrate = 9600

#for windows
ser.port = 2 #for COM3

ser.open()
ser.write('hello')
ser.close()

更新:由于我讨厌我的同事的提示音。我能得到它来通过耳机音频插孔?

UPDATE: Since I'm annoying my co-workers with the beep. Can I get it to come through the audio jack for headphones?

推荐答案

如果您只想让电脑做一个蜂鸣声:

If you want to just make the computer make a beep sound:

import winsound
Freq = 2500 # Set Frequency To 2500 Hertz
Dur = 1000 # Set Duration To 1000 ms == 1 second
winsound.Beep(Freq,Dur)

该winsound.Beep可以不管你想要的蜂鸣发生被使用。

The winsound.Beep can be used wherever you want the Beep to occur.

这篇关于Python的:制作一个消音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆