Detecting and printing timestamps of periods of silence using SoX

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Detecting and printing timestamps of periods of silence using SoX

Rahul Rajaram
Hi,

This mail is in reference to a question I posted on StackOverflow recently. In short, I want to be able to print the start-stop times of silences in an audio file, which eventually gets cut into pieces with the silences discarded. The exact text I posted was the following:

I am trying to output the begin-timestamps of periods of silence (since there is background noise, by silence I mean a threshold) in a given audio file. Eventually, I want to split the audio file into smaller audio files, given these timestamps. It is important that no part of the original file be discarded.

I tried

sox in.wav out.wav silence 1 0.5 1% 1 2.0 1% : newfile : restart

(courtesy http://digitalcardboard.com/blog/2009/08/25/the-sox-of-silence/)

Although, it somewhat did the job, it also trimmed and discarded the periods of silence, which I do not want happening.

Is 'silence' the right option, or is there a simpler way to accomplish what I need to do?

Thanks.


To this, I got a reply telling me that I can only do this by modifying the source code. I tried hard for long but could not make out which file(s) I am supposed to modify. I hope that you can help me.

Thanks,
Rahul Rajaram.



------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Detecting and printing timestamps of periods of silence using SoX

Jan Stary
On Aug 17 19:02:31, [hidden email] wrote:

> Hi,
>
> This mail is in reference to a question I posted on StackOverflow recently.
> In short, I want to be able to print the start-stop times of silences in an
> audio file, which eventually gets cut into pieces with the silences
> discarded. The exact text I posted was the following:
>
> *I am trying to output the begin-timestamps of periods of silence (since
> there is background noise, by silence I mean a threshold) in a given audio
> file. Eventually, I want to split the audio file into smaller audio files,
> given these timestamps. It is important that no part of the original file
> be discarded.*
>
> *I tried *
>
> *sox in.wav out.wav silence 1 0.5 1% 1 2.0 1% : newfile : restart*
>
> *(courtesy http://digitalcardboard.com/blog/2009/08/25/the-sox-of-silence/)*
>
> *Although, it somewhat did the job, it also trimmed and discarded the
> periods of silence, which I do not want happening. *
>
> *Is 'silence' the right option, or is there a simpler way to accomplish
> what I need to do?*
>
> *Thanks.*
>
> To this, I got a reply telling me that I can only do this by modifying the
> source code. I tried hard for long but could not make out which file(s) I
> am supposed to modify. I hope that you can help me.

$ cd sox-14.4.1/                                                  
$ find . -name silence\*
./src/silence.c


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Detecting and printing timestamps of periods of silence using SoX

Ulrich Klauer-2
In reply to this post by Rahul Rajaram
Rahul Rajaram wrote:

> To this, I got a reply telling me that I can only do this by modifying the
> source code. I tried hard for long but could not make out which file(s) I
> am supposed to modify. I hope that you can help me.

As Jan already showed, it is not that hard to find. Most effects live  
in a file src/${effect_name}.c.

silence.c isn't particularly easy to read. Best to look for the goto  
statements, they indicate when there is a change from copying to  
removing or the other way round.

Ulrich

(For reference: SO question  
http://stackoverflow.com/questions/18069794, old feature request  
http://sourceforge.net/p/sox/feature-requests/91/)


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users