Reputation: 21
I am trying to run the simple code, to play the wav sound with playsound (I found this way of sound playing on some website):
from playsound import playsound
playsound("Piano.wav")
and when I run it, I get error:
Traceback (most recent call last):
File "C:/Users/user/AppData/Local/Programs/Python/Python38/ьгышсф.py", line 3, in <module>
playsound("Piano.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
Same for mp3 files. And I am using Python 3.8
Upvotes: 2
Views: 5949
Reputation: 1
You usually get this error when an non-UTF-8 character is in your path (like Ü, Ö...). Try to avoid having such characters in the path of your sound file.
Upvotes: 0
Reputation: 28509
The error you get (275
= MCIERR_FILE_NOT_FOUND
) is that the system cannot find the sound file. You need to specify the complete path to the file, not only the file name:
playsound("C:\\Path\\To\\Piano.wav")
If the sound file is in the same directory or a subdirectory of where the script file is placed, see How to properly determine current script directory? for how to get the path to the script file at runtime.
Upvotes: 2