我正在尝试使用playsound
模块在Python中制作一个简单的节拍器。但是当我运行它时,出现以下错误:
Traceback (most recent call last):
File "/run/media/mb/Volume/Dokumente/Coding/Python/Metronom/metronom.py", line 5, in <module>
playsound("Cowbell.wav")
File "/usr/lib/python3.7/site-packages/playsound.py", line 106, in _playsoundNix
"playbin.set_state returned " + repr(set_result))
playsound.PlaysoundException: playbin.set_state returned <enum GST_STATE_CHANGE_FAILURE of type Gst.StateChangeReturn>
#if its in the same folder as project
playsound('file.mp3')
#somewhere else? then full path (REMEMBER PYTHON USES FORWARDSLASHES /, NOT BACKSLASHES )
playsound('C:/your/path/to/file.mp3')
还要注意,如果某些文件的比特率足够高,它们会引发播放异常(idk 为什么,我想 playsound 无法处理一些高质量的比特率)