症状
↓のようなエラーが出て再生できなかった (Raspberry Pi OS @ Raspberry Pi 2B)
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 261, in <module>
playsound(argv[1])
File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 163, in _playsoundNix
gi.require_version('Gst', '1.0')
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 254, in <lambda>
playsound = lambda sound, block = True: _playsoundAnotherPython('/usr/bin/python3', sound, block, macOS = False)
File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 229, in _playsoundAnotherPython
t.join()
File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 218, in join
raise self.exc
File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 211, in run
self.ret = self._target(*self._args, **self._kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/playsound.py", line 226, in <lambda>
t = PropogatingThread(target = lambda: check_call([otherPython, playsoundPath, _handlePathOSX(sound) if macOS else sound]))
File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '/home/pi/.local/lib/python3.7/site-packages/playsound.py', 'chime.mp3']' returned non-zero exit status 1.
解決方法
GitHubのissueに解決策がありました。
python版gstreamerが入っていないことが原因らしいので
sudo apt install python3-gst-1.0
でちゃんと音声が再生されるようになります。