Anyone can give a hint on what would be the best way to remove the silence from an audio stream? Not only silence from the beginning and the end, i want to remove all the silence from the stream and output only the voice.
cutter seens to do something like this (sending signals) but i cant make it do exactly what i want, i dont want to know when silence starts and ends, i want it removed from the stream :-). best regards, Katcipis -- "it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov ------------------------------------------------------------------------------ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Tiago Katcipis schrieb:
> Anyone can give a hint on what would be the best way to remove the > silence from an audio stream? Not only silence from the beginning and > the end, i want to remove all the silence from the stream and output > only the voice. > > cutter seens to do something like this (sending signals) but i cant > make it do exactly what i want, i dont want to know when silence > starts and ends, i want it removed from the stream :-). if you know the positions, then you could play a series of segmented seeks (see GST_SEEK_FLAG_SEGMENT from the docs). You might want to re-timestamp the buffers to make it a continous audiostream (you can use a pad-probe for it). Altogether not really a beginner project. Stefan > > best regards, > Katcipis > > -- > "it might be a profitable thing to learn Java, but it has no > intellectual value whatsoever" Alexander Stepanov > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel > ------------------------------------------------------------------------------ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Thanks for the help Stefan, right now im using an proprietary solution, i created an element and im using the proprietary solution inside (an audio filter). But i would like to use gstreamer open source solutions, but if it will take to much work to make it work ill have to keep with the proprietary solution :-( (damn deadlines).
Best regards, Katcipis On Fri, Jul 24, 2009 at 11:27 AM, Stefan Kost <[hidden email]> wrote: Tiago Katcipis schrieb: -- "it might be a profitable thing to learn Java, but it has no intellectual value whatsoever" Alexander Stepanov ------------------------------------------------------------------------------ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Hi,
I know that this thread is dead and its been a long time since the question was asked. Currently even I am trying to work on removing silence from the audio file / audio stream. I have tried using "level" and got the exact GstClockTime where the silence starts and end. I tried using gst_element_seek but no luck there. can anyone guide me or provide any code snippet which will help remove silent part from the audio stream/ |
On Fr, 2016-02-26 at 04:55 -0800, Sagar wrote:
> Hi, > > I know that this thread is dead and its been a long time since the > question was asked. Currently even I am trying to work on removing silence > from the audio file / audio stream. I have tried using "level" and got the > exact /GstClockTime/ where the silence starts and end. > > I tried using /gst_element_seek/ but no luck there. can anyone guide me or > provide any code snippet which will help remove silent part from the audio > stream/ silence from a stream would be to write an element that analyses the audio and drops any audio that is considered silence. It could optionally also offset the following timestamps to make it appear as if nothing was dropped. Doing this based on GstBaseTransform should be relatively simple. (Same goes for your other question about splitting on silence, you need something that detects silence and then does something about it) -- Sebastian Dröge, Centricular Ltd · http://www.centricular.com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel signature.asc (968 bytes) Download Attachment |
On Sat, 2016-02-27 at 19:22 +0200, Sebastian Dröge wrote:
> Seeking is not going to help you much indeed. The best for removing > silence from a stream would be to write an element that analyses the > audio and drops any audio that is considered silence. It could > optionally also offset the following timestamps to make it appear as > if nothing was dropped. The 'cutter' element should be able to do that already. A correctly- configured 'audioparse' element after it could then be used to make the audio look like a single continuous stream, unless you just want to remove the silent bits but maintain the timestamps. Cheers -Tim -- Tim Müller, Centricular Ltd - http://www.centricular.com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
I came across a bad plugin, "removesilence" but i am not able to find any documentation related to it and no examples are available online, is it a good idea to use a bad plugin ?
|
Il 29/02/2016 07:10, Sagar ha scritto:
> I came across a bad plugin, "removesilence" but i am not able to find any > documentation related to it and no examples are available online, is it a > good idea to use a bad plugin ? I used it with no troubles some years ago, I submitted some patch not yet merged too https://bugzilla.gnome.org/show_bug.cgi?id=671954 maybe can be useful for you too (not tested again current master) Nicola > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Removing-silence-from-a-stream-tp973199p4676100.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
thanks for your quick response, the patch which you proposed is more than 2-3 years old... still no action taken about it :(
I'm new to gstreamer and I will try to use your patch but I don't think I wil be able to do so, can you prove the compiled plug-in which i can use directly. |
Il 29/02/2016 10:38, Sagar ha scritto:
> thanks for your quick response, the patch which you proposed is more than 2-3 > years old... still no action taken about it :( > I'm new to gstreamer and I will try to use your patch but I don't think I > wil be able to do so, can you prove the compiled plug-in which i can use > directly. removesilence should work as is, my patch it is useful to remove timestamp gap when you remove silence, Nicola > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Removing-silence-from-a-stream-tp973199p4676105.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
I am using gst-launch-1.0 -v -t -m filesrc location=myvideo.webm ! decodebin ! audioconvert ! removesilence remove=true ! pulsesink what I want is that the audio to be played with out the silence
but remove silence doesnt seem to be doing that. I also tried an alternative method by using valve but there is some timestamp issue because of which some voice audio is lost. #define GLIB_DISABLE_DEPRECATION_WARNINGS #include <gst/gst.h> #include <string.h> #include <math.h> static GMainLoop *loop; GstElement *play; GstElement *valve; int isSpeaking =1; GstClockTime silencestarttime = 0; GstClockTime silenceendtime = 0; static gboolean my_voice_callback (GstBus *bus, GstMessage *message, gpointer data) { if (message->type == GST_MESSAGE_EOS) { g_main_loop_quit (loop); } return TRUE; } static gboolean my_bus_callback (GstBus *bus, GstMessage *message, gpointer data) { GstClockTime endtime; if (message->type == GST_MESSAGE_EOS) { if(isSpeaking ==0){ silenceendtime = endtime; g_print ("\tsilence start time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS (silencestarttime)); g_print ("\tsilence end time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS (silenceendtime)); } g_main_loop_quit (loop); } if (message->type == GST_MESSAGE_ELEMENT) { const GstStructure *s = gst_message_get_structure (message); const gchar *name = gst_structure_get_name (s); if (strcmp (name, "level") == 0) { gint channels; GstClockTime starttime; gdouble rms_dB, peak_dB, decay_dB; gdouble rms; const GValue *array_val; const GValue *value; GValueArray *rms_arr, *peak_arr, *decay_arr; gint i; if (!gst_structure_get_clock_time (s, "endtime", &endtime)) g_warning ("Could not parse endtime"); starttime = endtime - GST_SECOND; if(silencestarttime == 0){ silencestarttime =starttime ; } if(silenceendtime == 0){ silenceendtime =starttime; } /* the values are packed into GValueArrays with the value per channel */ array_val = gst_structure_get_value (s, "rms"); rms_arr = (GValueArray *) g_value_get_boxed (array_val); array_val = gst_structure_get_value (s, "peak"); peak_arr = (GValueArray *) g_value_get_boxed (array_val); array_val = gst_structure_get_value (s, "decay"); decay_arr = (GValueArray *) g_value_get_boxed (array_val); /* we can get the number of channels as the length of any of the value * arrays */ channels = rms_arr->n_values; for (i = 0; i < channels; ++i) { value = g_value_array_get_nth (rms_arr, i); rms_dB = g_value_get_double (value); value = g_value_array_get_nth (peak_arr, i); peak_dB = g_value_get_double (value); value = g_value_array_get_nth (decay_arr, i); decay_dB = g_value_get_double (value); if(rms_dB > -40){ if(isSpeaking ==0){ g_object_set(G_OBJECT(valve), "drop", FALSE , NULL); silenceendtime = starttime; g_print ("\tsilence start time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS (silencestarttime)); g_print ("\tsilence end time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS (silenceendtime)); } isSpeaking = 1; } else{ if(isSpeaking==1){ g_object_set(G_OBJECT(valve), "drop", TRUE , NULL); silencestarttime = starttime; } isSpeaking =0; g_print ("\nsilence: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS (starttime)); continue; } } } } /* we want to be notified again the next time there is a message * on the bus, so returning TRUE (FALSE means we want to stop watching * for messages on the bus and our callback should not be called again) */ return TRUE; } int main (int argc, char *argv[]) { GstBus *bus; /* gstreamer */ gst_init (&argc, &argv); /* we need to run a GLib main loop to get the messages */ loop = g_main_loop_new (NULL, FALSE); play = gst_parse_launch("filesrc location=audiosilence.mp4 ! decodebin ! audioconvert ! level interval=1000000000 !tee name=t ! queue ! fakesink t. ! queue ! valve name=valve ! audioconvert ! wavenc ! filesink location=valve.wav", NULL); g_assert (play); bus = gst_pipeline_get_bus (GST_PIPELINE (play)); gst_bus_add_watch (bus, my_bus_callback, NULL); gst_element_set_state (play, GST_STATE_PLAYING); valve = gst_bin_get_by_name(GST_PIPELINE (play),"valve"); g_main_loop_run (loop); gst_element_set_state (play, GST_STATE_NULL); gst_object_unref (GST_OBJECT (play)); gst_object_unref (bus); gst_object_unref (GST_OBJECT (valve)); g_main_loop_unref (loop); return 0; } P.S: What I want to achive is a non silent chunks audio. |
Hi,
can you share your input file please? Nicola Il 29/02/2016 11:11, Sagar ha scritto: > I am using /gst-launch-1.0 -v -t -m filesrc location=myvideo.webm ! decodebin > ! audioconvert ! removesilence remove=true ! pulsesink/ what I want is that > the audio to be played with out the silence > > but remove silence doesnt seem to be doing that. > > > I also tried an alternative method by using /valve/ but there is some > timestamp issue because of which some voice audio is lost. > > #define GLIB_DISABLE_DEPRECATION_WARNINGS > > #include <gst/gst.h> > #include <string.h> > #include <math.h> > > static GMainLoop *loop; > GstElement *play; > GstElement *valve; > > int isSpeaking =1; > GstClockTime silencestarttime = 0; > GstClockTime silenceendtime = 0; > > static gboolean > my_voice_callback (GstBus *bus, > GstMessage *message, > gpointer data) > { > if (message->type == GST_MESSAGE_EOS) { > g_main_loop_quit (loop); > } > return TRUE; > } > > static gboolean > my_bus_callback (GstBus *bus, > GstMessage *message, > gpointer data) > { > GstClockTime endtime; > if (message->type == GST_MESSAGE_EOS) { > if(isSpeaking ==0){ > silenceendtime = endtime; > g_print ("\tsilence start time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS > (silencestarttime)); > g_print ("\tsilence end time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS > (silenceendtime)); > > } > g_main_loop_quit (loop); > } > > if (message->type == GST_MESSAGE_ELEMENT) { > const GstStructure *s = gst_message_get_structure (message); > const gchar *name = gst_structure_get_name (s); > > if (strcmp (name, "level") == 0) { > gint channels; > GstClockTime starttime; > > gdouble rms_dB, peak_dB, decay_dB; > gdouble rms; > const GValue *array_val; > const GValue *value; > GValueArray *rms_arr, *peak_arr, *decay_arr; > gint i; > > if (!gst_structure_get_clock_time (s, "endtime", &endtime)) > g_warning ("Could not parse endtime"); > > starttime = endtime - GST_SECOND; > > if(silencestarttime == 0){ > silencestarttime =starttime ; > } > > if(silenceendtime == 0){ > silenceendtime =starttime; > } > > /* the values are packed into GValueArrays with the value per channel > */ > array_val = gst_structure_get_value (s, "rms"); > rms_arr = (GValueArray *) g_value_get_boxed (array_val); > > array_val = gst_structure_get_value (s, "peak"); > peak_arr = (GValueArray *) g_value_get_boxed (array_val); > > array_val = gst_structure_get_value (s, "decay"); > decay_arr = (GValueArray *) g_value_get_boxed (array_val); > > /* we can get the number of channels as the length of any of the value > * arrays */ > channels = rms_arr->n_values; > > for (i = 0; i < channels; ++i) { > value = g_value_array_get_nth (rms_arr, i); > rms_dB = g_value_get_double (value); > > value = g_value_array_get_nth (peak_arr, i); > peak_dB = g_value_get_double (value); > > value = g_value_array_get_nth (decay_arr, i); > decay_dB = g_value_get_double (value); > > if(rms_dB > -40){ > if(isSpeaking ==0){ > g_object_set(G_OBJECT(valve), "drop", FALSE , NULL); > > > silenceendtime = starttime; > g_print ("\tsilence start time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS > (silencestarttime)); > g_print ("\tsilence end time: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS > (silenceendtime)); > > } > isSpeaking = 1; > } > else{ > if(isSpeaking==1){ > g_object_set(G_OBJECT(valve), "drop", TRUE , NULL); > silencestarttime = starttime; > } > isSpeaking =0; > g_print ("\nsilence: %" GST_TIME_FORMAT "\n",GST_TIME_ARGS (starttime)); > continue; > } > } > } > } > > > /* we want to be notified again the next time there is a message > * on the bus, so returning TRUE (FALSE means we want to stop watching > * for messages on the bus and our callback should not be called again) > */ > return TRUE; > } > > int > main (int argc, char *argv[]) > { > > GstBus *bus; > > /* gstreamer */ > gst_init (&argc, &argv); > > /* we need to run a GLib main loop to get the messages */ > loop = g_main_loop_new (NULL, FALSE); > > play = gst_parse_launch("filesrc location=audiosilence.mp4 ! decodebin ! > audioconvert ! level interval=1000000000 !tee name=t ! queue ! fakesink t. > ! queue ! valve name=valve ! audioconvert ! wavenc ! filesink > location=valve.wav", NULL); > g_assert (play); > > > bus = gst_pipeline_get_bus (GST_PIPELINE (play)); > gst_bus_add_watch (bus, my_bus_callback, NULL); > > gst_element_set_state (play, GST_STATE_PLAYING); > > valve = gst_bin_get_by_name(GST_PIPELINE (play),"valve"); > g_main_loop_run (loop); > > gst_element_set_state (play, GST_STATE_NULL); > gst_object_unref (GST_OBJECT (play)); > > gst_object_unref (bus); > > gst_object_unref (GST_OBJECT (valve)); > g_main_loop_unref (loop); > > return 0; > } > > > > > P.S: What I want to achive is a non silent chunks audio. > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Removing-silence-from-a-stream-tp973199p4676108.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
I guess I was assuming the functionality of level/cutter wrong, I thought output will be non-silence audio
I used something like this gst-launch filesrc location=audiowithsilence.mp4 ! decodebin ! audioconvert ! cutter threshold-dB=-41 run-length=300000000 !tee name=t ! queue ! fakesink t. ! queue ! valve name=valve ! audioconvert ! wavenc ! filesink output.wav when ever the callback from cutter above is true I drop</d> the value to true and when the above value is false i close it. but being a newbie I feel that there is not much example samples on the internet when it comes to gstreamer. Thanks for your help. Happy Coding.... |
Hi,
I rebased my patch for removesilence against current master, I tested with a pipeline like this: filesrc location=/tmp/input.wav ! wavparse ! audioconvert ! audioresample ! removesilence remove=true squash=true ! wavenc ! filesink location=/tmp/output.wav input.wav was 19 seconds long and contains about 5 seconds of silence, the generated output.wav is 14 seconds long and contain no silence, you can find updated patch here: https://bugzilla.gnome.org/show_bug.cgi?id=671954 Nicola Il 02/03/2016 08:17, Sagar ha scritto: > I guess I was assuming the functionality of level/cutter wrong, I thought > output will be non-silence audio > > I used something like this /gst-launch filesrc location=audiowithsilence.mp4 > ! decodebin ! audioconvert ! cutter threshold-dB=-41 run-length=300000000 > !tee name=t ! queue ! fakesink t. ! queue ! valve name=valve ! audioconvert > ! wavenc ! filesink output.wav/ > > when ever the callback from cutter *above* is true I *drop</d> the value to > *true* and when the above value is false i close it. > > but being a newbie I feel that there is not much example samples on the > internet when it comes to gstreamer. > > Thanks for your help. > Happy Coding.... > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Removing-silence-from-a-stream-tp973199p4676127.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
This post was updated on .
Hi,
Thanks for your efforts and your reply, I will take a look at the patch and try to build the .so file. I will get back to you on this soon... If possible can you please post the gstremovesilence.c and gstremovesilence.h files ? |
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
|
Hi guys,
I have worked on the patch provided by Nicola and created a new git repo https://github.com/sagarpilkhwal/gst-plugins-bad Let me know if you guys see any issues in the code when get a change to review the code. Regards, Sagar Pilkhwal |
Hi,
thanks for your effort, I did a quick look to your patch, the only relevant addition seems a new signal that post on the bus the voice buffer, I don't like much this way to do the things, generally the buffer timestamp is posted on the bus and not the whole buffer but maybe this can be useful for your use case I think the only missing piece is to make VAD_POWER_THRESHOLD configurable: you changed the hardcoded value from -40 dB to -35 dB but this seems still not configurable anyway I don't use the plugin anymore and since seems there is no interest upstream I'm not motivated to send a new patch to make the threshold configurable, Nicola Il 20/09/2016 10:11, Sagar ha scritto: > Hi guys, > > I have worked on the patch provided by Nicola and created a new git repo > https://github.com/sagarpilkhwal/gst-plugins-bad > <https://github.com/sagarpilkhwal/gst-plugins-bad> > > Let me know if you guys see any issues in the code when get a change to > review the code. > > Regards, > Sagar Pilkhwal > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Removing-silence-from-a-stream-tp973199p4679663.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Thanks of taking a look into the code, I wanted the upstream messages as I wish to gather these non-silent audio buffer and later send them to some webservice to get text from audio. And yes, the VAD_POWER_THRESHOLD parameter should be configurable. I will work on it
Regards, Sagar Pilkhwal |
Il 20/09/2016 11:32, Sagar ha scritto:
> Thanks of taking a look into the code, I wanted the upstream messages as I > wish to gather these non-silent audio buffer and later send them to some > webservice to get text from audio. And yes, the VAD_POWER_THRESHOLD > parameter should be configurable. I will work on it vad threshold is now configurable https://bug671954.bugzilla-attachments.gnome.org/attachment.cgi?id=344247 Nicola > > Regards, > Sagar Pilkhwal > > > > -- > View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Removing-silence-from-a-stream-tp973199p4679666.html > Sent from the GStreamer-devel mailing list archive at Nabble.com. > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |