TaylorSMarks / playsound

Pure Python, cross platform, single function module with no dependencies for playing sounds.
Other
523 stars 114 forks source link

Gst #27

Open sfsdfd opened 5 years ago

sfsdfd commented 5 years ago

~ $ pip install --user playsound Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting playsound Using cached https://files.pythonhosted.org/packages/f5/16/10d897b0a83fb4b05b03a63d7a2667ab75f857f67f7062fd447dd3f49bf7/playsound-1.2.2-py2.py3-none-any.whl Installing collected packages: playsound Successfully installed playsound-1.2.2

~ $ python Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information.

from playsound import playsound playsound('./example.mp3')

Traceback (most recent call last): File "", line 1, in File "/home/neopixel/.local/lib/python2.7/site-packages/playsound.py", line 92, in _playsoundNix gi.require_version('Gst', '1.0') File "/usr/lib/python2.7/dist-packages/gi/init.py", line 118, in require_version raise ValueError('Namespace %s not available' % namespace) ValueError: Namespace Gst not available

exit()

~ $ pip uninstall playsound Uninstalling playsound-1.2.2: Would remove: /home/neopixel/.local/lib/python2.7/site-packages/playsound-1.2.2.dist-info/* /home/neopixel/.local/lib/python2.7/site-packages/playsound.py Proceed (y/n)? Y Successfully uninstalled playsound-1.2.2

catmatist commented 3 years ago

Playsound needs gstreamer installed. How make it be installed depends on which Linux you are running; on my Ubuntu it was already there and working. On latest (start of 2021) Raspberry OS, it's not there and I just run paplay in a subprocess because I already had code for doing that and it's not performance-critical for me. But the right sudo apt incantation might get it working. My interest is, could it detect the problem at import time instead of waiting for the first use to detect the problem? Why does it redo all the initialization for every call to the function? Is that really necessary?

zackees commented 1 year ago

Hitting this issue in a github ubuntu worker.

Adding this line fixed it to the *.yml file.

    - name: Install ubuntu sound drivers
      run: sudo apt-get install gir1.2-gst-plugins-base-1.0 gir1.2-polkit-1.0 gpicview gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-x

Many of these libraries are probably unnecessary