用于播放固定频率声音的Python库,无需外部模块

问题描述 投票:0回答:1

我有一个程序,我想在没有间隙的情况下播放设定的频率声音,直到我告诉它停止。我见过this的答案,但这需要一个外部模块(我在离线环境中工作,所以这是不可能的)。

另外,this答案也不太实用,因为它会有播放间隙(虽然可以创建文件)。我希望我所要求的并非不可能,但我有一种感觉。

提前致谢。

python audio
1个回答
1
投票

我确信我已经从stdlib模块中做到了,只是不记得如何或在什么平台上。但是这看起来很像你想要的(对于windows,至少),来自python帮助:

winsound.Beep(frequency, duration)

Beep the PC’s speaker. The frequency parameter specifies frequency,
in hertz, of the sound, and must be in the range 37 through 32,767.
The duration parameter specifies the number of milliseconds the sound
should last.
If the system is not able to beep the speaker, RuntimeError is raised.
© www.soinside.com 2019 - 2024. All rights reserved.