I am making a morse code program so I need to use loops with playsound module to play the short and long beeps again and again. The files are playing properly without a loop but when I add a loop I run into an error.
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.