RuntimeError: Error opening 'female_present.wav': File contains data in an unknown format

As indicated in the title, the sound module doesn’t play my file and says it’s of an unknown format, despite being a .wav. Here’s the code below:

present_female = sound.Sound('female_present.wav')
present_female.play()

I’ve also tried with:

voice = py.sound.backend_pygame.SoundPygame(value ='female_present.wav')
voice.play()

and that gives me “ValueError: Sound file female_present.wav could not be opened using pygame for sound.”

Thanks in advance for your help!

What was the file made in, and can you get any information about its encoding beyond the fact that it’s .wav? Bitrate, frequency?

It was generated online and downloaded as an m4a. I then converted to .wav

It’s got a sample rate of 48kHz. Beyond that I’m not sure. I’ve attached the file below.

Bottom line is I’m trying to send a voice response of something like “The target is present”. I’ve been able to do that straight to command line with ‘say’ for Macs, but haven’t had any success finding an equivalent commands with other platforms like windows.

Interesting. You’re trying to play it locally in Python, right? What sound library are you using? This can be found under preferences. By default it will use whatever library is listed first, I recommend either sounddevice or PTB. You could also experiment with other sound formats. mp3 will not work, but .aiff or something might.

I suspect that the wav file in question is compressed, which isn’t supported by the pygame library you use: https://stackoverflow.com/questions/47640886/pygame-will-only-play-some-wav-files

You could convert the file to an uncompressed wav. Then, it should work.

Thanks! I just wound up recreating the files as .aiff and it seemed to work. Thanks for the help!