I've run into the same issue a couple of times recently when using the playsound
module on Windows 10. I found that, when playing shorter (around 3 seconds) audio clips, playsound
cut the end of it despite the original audio being complete. I noticed two interesting aspects:
- For the same audio clip, the time when audio is cut differs from one run to the next.
- I couldn't reproduce this when playing longer audios, it only occured with audios up to 5 seconds or so. (Although to be honest, I didn't try an awful lot of options.)
One workaround I figured out seems to work perfectly to me: I added a simple time.sleep(1)
right after playsound.playsound()
like this:
import playsound
import os
import time
DIR_NAME = "path/to/dir/where/you/store/audio/files/that/you/want/to/play"
playsound.playsound(os.path.join(DIR_NAME,'myaudio_001.mp3'))
time.sleep(1)
Note that depending on the length of your audios, you might want to increase the waiting time from 1 second to a bit more.