winsound

How to play different sound consecutively and asynchronously in python?

房东的猫 提交于 2021-01-29 12:08:58
问题 To be specific, I need to play sound in a while loop which is fast to execute. And the audio needs to be played separately. I've tried various functions/libraries: playsound, winsound, vlc. But none of them meet my demand. Either the sounds are overlapped, or I need to wait for the sound to finish to continue the next line of code, which blocks the whole process, making the program running with unbearable lags. Matters in playsound, winsound, vlc: playsound: has block option but will block

Python winsound, ASYNC flag not working?

十年热恋 提交于 2020-01-24 20:40:06
问题 I'm using python 3.5 and I'm trying to play a sound while continuing right away with my script; according to https://docs.python.org/3.5/library/winsound.html the flag "winsound.SND_ASYNC" should be the way to go. However the following doesn't produce any sound: import winsound winsound.PlaySound('C:/Users/Bob/Sounds/sound.wav', winsound.SND_ASYNC) Interesting enough if I change the flag to "winsound.SND_FILENAME the sound is played: import winsound winsound.PlaySound('C:/Users/Bob/Sounds

ModuleNotFoundError at /admin No module named 'winsound'

冷暖自知 提交于 2019-12-13 02:55:59
问题 I am developing an app in Django. My app plays a sound using winsound module. import sys import winsound duration = 150 # milliseconds freq = 440 # Hz winsound.Beep(freq, duration) winsound.Beep(freq, duration) winsound.Beep(freq, duration) It worked fine as soon as I was developing in local, but when I pushed the app to heroku and then tryed to access the admin section, the web returned the error ModuleNotFoundError at /admin No module named 'winsound' So I tryed to pip install windsound ,

How to stop music if Enter key is pressed anytime the program is running?

最后都变了- 提交于 2019-12-11 14:52:20
问题 I want my program do something along the lines of: while this program is running: if the Enter key is pressed, stop the current music file playing. Here is my code: # https://docs.python.org/2/library/winsound.html from msvcrt import getch import winsound while True: key = ord(getch()) if key == 13: winsound.PlaySound(None, winsound.SND_NOWAIT) winsound.PlaySound("SystemAsterisk", winsound.SND_ALIAS) winsound.PlaySound("SystemExclamation", winsound.SND_ALIAS) winsound.PlaySound("SystemExit",