我正在制作一个莫尔斯电码程序,所以我需要使用带有 playsound 模块的循环来一次又一次地播放短而长的哔哔声。这些文件在没有循环的情况下正常播放,但是当我添加一个循环时,我遇到了错误。
from playsound import playsound
import time
for i in range(0, 5):
playsound('long.mp3')
time.sleep(0.5)
playsound('short.mp3')
time.sleep(0.5)
Error 263 for command: open long.mp3 The specified device is not open or is not recognized by MCI. Error 263 for command: close long.mp3 The specified device is not open or is not recognized by MCI. Failed to close the file: long.mp3 Traceback (most recent call last): File "C:\Users\achin\PycharmProjects\Morse code\ok.py", line 5, in <module> playsound('long.mp3') File "C:\Users\achin\PycharmProjects\Morse code\venv\lib\site-packages\playsound.py", line 72, in _playsoundWin winCommand(u'open {}'.format(sound)) File "C:\Users\achin\PycharmProjects\Morse code\venv\lib\site-packages\playsound.py", line 64, in winCommand raise PlaysoundException(exceptionMessage) playsound.PlaysoundException: Error 263 for command: open long.mp3 The specified device is not open or is not recognized by MCI.