happyleavesaoc / gstreamer-player Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I experienced what a few people are seeing over at home-assistant/core#7515 and tried the proposed fix of putting a time.sleep(0.1)
call in the while True
loop. It reduced cpu usage from 100% to 2%.
I am using this with homeassistant for tts. Since I'm using PulseAudio to mix various continuous streams, my pipeline is simply pulsesink
(rather than the snapcast fifo). However, whenever hass tries to use this, it gives this error:
gst-resource-error-quark: Failed to create context
I have turned up gstreamer debugging by setting GST_DEBUG=6
, which provided some relevant messages on syslog:
pulse pulsesink.c:533:gst_pulseringbuffer_open_device:<pulsesink0>#033[00m new context with name python3@localhost, pbuf=0x7f0284538050, pctx=0x7f02844971a0
pulse pulsesink.c:608:gst_pulseringbuffer_open_device:<pulsesink0>#033[00m error: Failed to create context
GST_MESSAGE gstelement.c:2110:gst_element_message_full_with_details:<pulsesink0>#033[00m start
GST_ERROR_SYSTEM gstelement.c:2141:gst_element_message_full_with_details:<pulsesink0>#033[00m posting message: Failed to create context
GST_MESSAGE gstmessage.c:305:gst_message_new_custom:#033[00m source pulsesink0: creating new message 0x7f0284537030 error
structure gststructure.c:1863:priv_gst_structure_append_to_gstring:#033[00m No value transform to serialize field 'gerror' of type 'GError'
GST_BUS gstbus.c:316:gst_bus_post:<bus3>#033[00m [msg 0x7f0284537030] posting on bus error message: 0x7f0284537030, time 99:99:99.999999999, seq-num 16, element 'pulsesink0', GstMessageError, gerror=(GError)NULL, debug=(string)"pulsesink.c\(608\):\ gst_pulseringbuffer_open_device\ \(\):\ /GstBin:bin0/GstPulseSink:pulsesink0";
bin gstbin.c:3716:gst_bin_handle_message_func:<bin0>#033[00m [msg 0x7f0284537030] handling child pulsesink0 message of type error
bin gstbin.c:3723:gst_bin_handle_message_func:<bin0>#033[00m got ERROR message, unlocking state change
Deep down, the error comes from line 608 of https://github.com/GStreamer/gst-plugins-good/blob/master/ext/pulse/pulsesink.c
Desperately searching for a similar error, I tried setting GST_GL_WINDOW=gbm
as well to no avail.
Annoyingly, outside of home assistant, but as the same user in the same venv, the following does work:
>>> from gsp import GstreamerPlayer
>>> player = GstreamerPlayer('pulsesink')
>>> player.queue("file:///80s/Animotion - Obsession.mp3")
On PyPI we have 1.1.2 but on GitHub we are still on 1.1.0.
I didn't want to hijack the other quark issue, but I also get this error, for me it is in combination with home assistant. When I try to play something via TTS i get the following error in the hass log:
2017-08-16 18:45:37 ERROR (SyncWorker_0) [gsp] gst-resource-error-quark: Could not open resource for reading. (5)
My hass configuration:
tts:
- platform: picotts
language: 'de-DE'
media_player:
- platform: gstreamer
name: 'tts'
pipeline: 'audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapfifo'
Playing from command line is working:
$ python3
Python 3.6.1 (default, Mar 28 2017, 16:46:16)
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gsp import GstreamerPlayer
>>> player = GstreamerPlayer(None)
>>> player.queue("/home/user/testfiles/mpthreetest.mp3")
The snapcast fifo is there and the snapcast server<->client is working as well, for example if I use mpv to send something it plays just fine, e.g. with
$ mpv mpthreetest.mp3 --audio-display=no --audio-channels=stereo --audio-samplerate=48000 --audio-format=s16 --ao=pcm --ao-pcm-file=/tmp/snapfifo
And TTS over Snapcast also works fine on command line:
$ pico2wave --lang=de-DE --wave=/tmp/test.wav "test 1 2 3 4 5" ; mpv /tmp/test.wav --audio-display=no --audio-channels=stereo --audio-samplerate=48000 --audio-format=s16 --ao=pcm --ao-pcm-file=/tmp/snapfifo
Also plain gst-play-1.0 is working and it can play the wav file from pico2wave:
$ pico2wave --lang=de-DE --wave=/tmp/test.wav "test 1 2 3 4 5"
$ gst-play-1.0 /tmp/test.wav
What also works fine is sending the file to the fifo with the parameters used by the homeassistant pipeline:
gst-launch-1.0 -v uridecodebin uri=file:///tmp/test.wav ! audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapfifo
Hello Sir,
I installed gstreamer-player and tried to import the package.
from gsp import GstreamerPlayer
Got the error;
ModuleNotFoundError: No module named 'gsp'
Could you pls help
The project is just what i needed but sadly doesn't work for me.
Python 3.5.2 under Linux
>>> from gsp import GstreamerPlayer
>>> player = GstreamerPlayer(None)
>>> player.queue("2.mp3")
gst-resource-error-quark: Could not open resource for reading. (5)
gstreamer work for me with my code i wrote a hacky version of the wrapper but really want queue management. Thanks for the code btw
I'm getting this error while executing the usage example with my regular Raspberry Pi user.
Same audio file plays nice with aplay.
Python 3.9.2
Process GstreamerProcess-2:
Traceback (most recent call last):
File "/usr/lib/python3.9/multiprocessing/managers.py", line 801, in _callmethod
conn = self._tls.connection
AttributeError: 'ForkAwareLocal' object has no attribute 'connection'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/home/user/.local/lib/python3.9/site-packages/gsp/__init__.py", line 95, in run
self.media(uri)
File "/home/user/.local/lib/python3.9/site-packages/gsp/__init__.py", line 120, in media
self.state = STATE_PLAYING
File "/home/user/.local/lib/python3.9/site-packages/gsp/__init__.py", line 168, in state
self._manager[ATTR_STATE] = state
File "<string>", line 2, in __setitem__
File "/usr/lib/python3.9/multiprocessing/managers.py", line 805, in _callmethod
self._connect()
File "/usr/lib/python3.9/multiprocessing/managers.py", line 792, in _connect
conn = self._Client(self._token.address, authkey=self._authkey)
File "/usr/lib/python3.9/multiprocessing/connection.py", line 507, in Client
c = SocketClient(address)
File "/usr/lib/python3.9/multiprocessing/connection.py", line 635, in SocketClient
s.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused
Any idea is welcome
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.