gpt4 book ai didi

Python winsound,ASYNcflags不起作用?

转载 作者:行者123 更新时间:2023-12-03 19:38:01 25 4
gpt4 key购买 nike

我正在使用 python 3.5,我正在尝试播放声音,同时继续我的脚本;根据 https://docs.python.org/3.5/library/winsound.html标志“winsound.SND_ASYNC”应该是要走的路。但是,以下不会产生任何声音:

import winsound
winsound.PlaySound('C:/Users/Bob/Sounds/sound.wav', winsound.SND_ASYNC)

如果我将标志更改为“winsound.SND_FILENAME,播放声音就足够有趣了:
import winsound
winsound.PlaySound('C:/Users/Bob/Sounds/sound.wav', winsound.SND_FILENAME)

任何想法为什么异步标志不起作用?

最佳答案

根据docs ,

The sound parameter may be a filename, audio data as a string, or None. Its interpretation depends on the value of flags, which can be a bitwise ORed combination of the constants described below



类似如下:
import winsound
winsound.PlaySound('C:/Users/Bob/Sounds/sound.wav', winsound.SND_FILENAME | winsound.SND_ASYNC)

关于Python winsound,ASYNcflags不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45128232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com