How can I play audio (playsound) in the background of a Python script?
Just change True to False (I use Python 3.7.1) import playsound playsound.playsound(‘storm.mp3’, False) print (‘…’)
Just change True to False (I use Python 3.7.1) import playsound playsound.playsound(‘storm.mp3’, False) print (‘…’)
I faced this problem too firstly as mentioned in the previous comments I downgraded my python version from 3.10 to 3.7 and yet the problem persisted. So what actually worked is that the recent versions of playsound are giving such errors in order to fix this run the following commands in cmd as admin pip … Read more
You can use the multiprocessing module to play the sound as a background process, then terminate it anytime you want: import multiprocessing from playsound import playsound p = multiprocessing.Process(target=playsound, args=(“file.mp3”,)) p.start() input(“press ENTER to stop playback”) p.terminate()