0

So when I try to play a .wav or .mp3 audio file with playsound in python, it gives me this error:

Traceback (most recent call last):
  File "c:\Users\user\Desktop\files lol\Programming\Python\packages\soundlib\soundlib\beep.py", line 3, in <module>
    play('beep.wav')
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\playsound.py", line 35, in _playsoundWin
    winCommand('open "' + sound + '" alias', alias)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\playsound.py", line 30, in winCommand
    '\n    ' + errorBuffer.value.decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte

The python code:

from playsound import playsound as play

play('beep.wav')

The version of playsound I use is 1.2.2, since 1.3.0 just doesn't work.

Edit: I don't think it's a problem with the file, since even if I just do play(''), it gives me that error.

Cube
  • 1
  • 4
  • Since the problem is with the file, I bet it would help a lot to upload the file somewhere or post a link to where you got it from. – Joooeey Aug 03 '22 at 13:22
  • 1
    @Joooeey it could also be a problem with the file path as well. I don't think wav files are concerned about character encoding. It's tough to say though since the error message surfaced by `playsound` isn't amazing. I see [here](https://stackoverflow.com/questions/58979872/why-do-i-have-utf-8-codec-cant-decode-byte-0xc4-in-position-0-invalid-conti) in the comments a suggestion to change the `playsound.py` file to surface the actual error which may help with troubleshooting. I've not used this module, but it doesn't give me the warm fuzzies. – JNevill Aug 03 '22 at 13:27
  • Looks like it's attempting to decode stderr from the underlying command. I don't particularly like the design of this module. – Mad Physicist Aug 03 '22 at 14:23

1 Answers1

0

It turns out the path was wrong. This is weird, because the path should've been soundlib/sounds/beep.wav even though the file was already located in the soundlib folder. I still don't know why it's like that.

Just found out that only happens in Visual Studio Code. What's the problem with paths in Visual Studio Code???

Cube
  • 1
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 05 '22 at 11:55