Can't Play .wav file with winsound module?

I am trying to play a .wav file like this:

import winsound
winsound.PlaySound('test.wav', winsound.SND_FILENAME)

When the script is ran there are no errors but a default windows alert sound is played instead of the test.wav file.


Solution 1:

Make sure the wav file you are trying to play is in the same folder as the py script is in. Otherwise you have to provide a correct relative path to the file or it won't find it. Example:

import winsound
import sys

winsound.PlaySound(Test.wav,winsound.SND_ASYNC)

With SND_ASYNC the windows beep shouldn't play and your wav file should play.