Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stopping the pipeline mid-decoding #33

Open
Aelos opened this issue Dec 8, 2015 · 3 comments
Open

Stopping the pipeline mid-decoding #33

Aelos opened this issue Dec 8, 2015 · 3 comments

Comments

@Aelos
Copy link

Aelos commented Dec 8, 2015

Hello,

I am using Kaldi in a way similar to your gstreamer server, and this plugin is a great help.

My issue is when decoding a file, either by using a filesrc element or by pushing buffers in an appsrc element. I cannot find a way to stop the decoding before it has reached the end of the file.
I see in your decoder you commented various lines that I have tried without success:

  • Sending an eos event will not work as the eos_handler will not be activated until the end of the file.
  • Changing the state of the pipeline (actually even only the decoder element) to READY or NULL will block until the end of the file has been decoded.
  • Setting the asr element to "silent" does not stop the decoding either.

Through chance I found a kind of workaround by using a tee element with on one side the asr decoder (without a fakesink) and on the other side a pulsesink. The pulsesink would receive the eos, throw an underflow warning and for some reason the asr element will stop as well. This however is not graceful at all and the server I want to run the service on doesn't have pulseaudio drivers. I believe this might also hinder performance.

I noted that this also happens with the other kaldi gstreamer plugin (gmmdecode) in the same way, whereas when using the pocketsphinx plugin, the behavior is as expected and pushing an eos event will stop the decoding.

My code is similar to the one you use in decoder2.py.

Would you know of a graceful way to stop the pipeline in order to have the decoder immediately available again?

@alumae
Copy link
Owner

alumae commented Dec 8, 2015

I don't think it's possible at the moment. In fact, I've struggled with this problem too. I think it one might need to make largish changes to the code to make it possible, and it is especially complicated with the threaded decoder.

When you push EOS to the pipeline, it gets consumed after all the buffers that have been already pushed to the pipeline. Therefore, I actually cannot see how the pocketsphinx plugin could handle it better. I used the pocketsphinx plugin as a reference when creating the the Kaldi GStreamer plugins.

@Aelos
Copy link
Author

Aelos commented Dec 9, 2015

I understand.

About PocketSphinx, in my simple pipeline filesrc -> decodebin -> audioconvert -> audioresample -> pocketsphinx -> fakesink, it seems that using pipeline.send_event(Gst.Event.new_eos()) works and the EOS is consumed almost immediately and the event handler called, even if the file is far from being fully decoded.

I do not fully understand yet the way buffers and events are consumed in Gstreamer, and especially why my workaround with the pulseaudio element works.

Thank you for your answer. I will keep you updated if I find a way.

@luvwinnie
Copy link

luvwinnie commented Jul 9, 2019

Hello, Thanks for this gstreamer plugins!

I trying to use this gstreamer plugins in my gstreamer python apps with "appsrc" method.
However i face the same problems for this.
Does anyone figure out how to solve this problem?

In my case, I trying to use pyaudio to record the sound wave and decoding.
PS:My code is similar to your decoder2.py just like @Aelos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants