Finding Silent Files

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

Finding Silent Files

Teledon
I am working with 25,000 audio files. A few of these files are completely silent. Some have very soft noises. I want to find all the files which never get louder than some specified level, The goal is to find and remove all the files with no or minimal audio in them.

In the best case, I would like to produce a list of the file names of all the quiet files in a text file. I am using Win7, so a Win7 command line would be the best for me. I also have a new MacBook Pro, so I could use a linux bash command line script in a pinch, but I would have to move all the 25K files over to the Mac.

This works for a single file in Win7: 
sox filename.wav -n stat

Samples read:              8480
Length (seconds):      1.060000
Scaled by:         2147483647.0
Maximum amplitude:     0.285034
Minimum amplitude:    -0.316284
Midline amplitude:    -0.015625
Mean    norm:          0.015215
Mean    amplitude:    -0.000088
RMS     amplitude:     0.040339
Maximum delta:         0.327881
Minimum delta:         0.000000
Mean    delta:         0.004365
RMS     delta:         0.015967
Rough   frequency:          503
Volume adjustment:        3.162

I can look at the Maximum amplitude value in this output to see what the loudest sound in the one specific file is.

Unfortunately, it would take too long to do this for all 25,000 files.

I tried:
sox *.wav -n stat 2> filestatlist.txt

but I get this error message:
sox FAIL formats: can't open input file `filename-23650.wav': Too many open files

I reduced the number of files in the directory and got:

Samples read:           3459520
Length (seconds):    432.440000
Scaled by:         2147483647.0
Maximum amplitude:     0.980347
Minimum amplitude:    -0.980347
Midline amplitude:     0.000000
Mean    norm:          0.024233
Mean    amplitude:     0.001230
RMS     amplitude:     0.097582
Maximum delta:         1.898193
Minimum delta:         0.000000
Mean    delta:         0.014612
RMS     delta:         0.065611
Rough   frequency:          856
Volume adjustment:        1.020

I realized that sox was catenating all the files in the directory, and then giving the stats for the final one BIG file. That doesn't help me. I need stats for each individual file.

I would at least like to get the sox stats for each file put into a single text file, as I can sort them from there. However, that txt file needs a way to identify which set of stats go with which audio file. In the best case, I would like to generate a text file with just all the low-volume file names in it.

Teledon


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Jan Stary
On Dec 26 09:41:03, Teledon wrote:

>  I am working with 25,000 audio files. A few of these files are completely
> silent. Some have very soft noises. I want to find all the files which
> never get louder than some specified level, The goal is to find and remove
> all the files with no or minimal audio in them.
>
> In the best case, I would like to produce a list of the file names of all
> the quiet files in a text file. I am using Win7, so a Win7 command line
> would be the best for me. I also have a new MacBook Pro, so I could use a
> linux bash command line script in a pinch, but I would have to move all the
> 25K files over to the Mac.
>
> This works for a single file in Win7:
> sox filename.wav -n stat
>
> Samples read:              8480
> Length (seconds):      1.060000
> Scaled by:         2147483647.0
> Maximum amplitude:     0.285034
> Minimum amplitude:    -0.316284
> Midline amplitude:    -0.015625
> Mean    norm:          0.015215
> Mean    amplitude:    -0.000088
> RMS     amplitude:     0.040339
> Maximum delta:         0.327881
> Minimum delta:         0.000000
> Mean    delta:         0.004365
> RMS     delta:         0.015967
> Rough   frequency:          503
> Volume adjustment:        3.162
>
> I can look at the Maximum amplitude value in this output to see what the
> loudest sound in the one specific file is.

This is all you need from SoX (or indeed any audio software that can
report the maximum amplitude). The rest is shell scripting.

> Unfortunately, it would take too long to do this for all 25,000 files.

If you want to know the maximum amplitude in each of the files,
theer is no way around reading all the samples in all the files.

> I tried:
> sox *.wav -n stat 2> filestatlist.txt
>
> but I get this error message:
> sox FAIL formats: can't open input file `filename-23650.wav': Too many open
> files

There is a limit to how many files SoX can simultaneously open.
Do it individually for each of the files.

> I reduced the number of files in the directory and got:
>
> Samples read:           3459520
> Length (seconds):    432.440000
> Scaled by:         2147483647.0
> Maximum amplitude:     0.980347
> Minimum amplitude:    -0.980347
> Midline amplitude:     0.000000
> Mean    norm:          0.024233
> Mean    amplitude:     0.001230
> RMS     amplitude:     0.097582
> Maximum delta:         1.898193
> Minimum delta:         0.000000
> Mean    delta:         0.014612
> RMS     delta:         0.065611
> Rough   frequency:          856
> Volume adjustment:        1.020
>
> I realized that sox was catenating all the files in the directory, and then
> giving the stats for the final one BIG file. That doesn't help me. I need
> stats for each individual file.

So do it in a loop, for each of the files.

> I would at least like to get the sox stats for each file put into a single
> text file, as I can sort them from there. However, that txt file needs a
> way to identify which set of stats go with which audio file. In the best
> case, I would like to generate a text file with just all the low-volume
> file names in it.

silent=0.1
find . -name file\*wav | sort | while read f; do
        max=`sox $f -n stat 2>&1 | grep Maximum amplitude | cut -d: -f2`
        [ `echo "$max < $silent" | bc` == 1 ] && echo $f
done

Obviously, you need to modify this for your shell,
possible ugly filenames etc.


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Ulrich Klauer-2
Jan Stary <[hidden email]>:

>> Unfortunately, it would take too long to do this for all 25,000 files.
> If you want to know the maximum amplitude in each of the files,
> theer is no way around reading all the samples in all the files.

True, but in this case it would be sufficient to stop as soon as the  
first sample exceeds the threshold. I don't think this can be done  
with SoX directly, without writing a custom effect; an idea would be  
to select the first second (or the third, if the files are long enough  
and typically fade in) of each file with trim, then analyze this,  
reducing the list of "silence candidates" that have to be checked  
completely.

Ulrich


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Fmiser
In reply to this post by Teledon
> Teledon wrote:

>  I am working with 25,000 audio files. A few of these files
> are completely silent. Some have very soft noises. I want to
> find all the files which never get louder than some specified
> level, The goal is to find and remove all the files with no or
> minimal audio in them.
>
> In the best case, I would like to produce a list of the file
> names of all the quiet files in a text file. I am using Win7,
> so a Win7 command line would be the best for me. I also have a
> new MacBook Pro, so I could use a linux bash command line
> script in a pinch, but I would have to move all the 25K files
> over to the Mac.

What about mounting the MSWin file system on the Mac over a
network?  Then SoX could run on the Mac and access the file on
Win7.

> This works for a single file in Win7:
> sox filename.wav -n stat

> I tried:
> sox *.wav -n stat 2> filestatlist.txt
>
> but I get this error message:
> sox FAIL formats: can't open input file `filename-23650.wav':
> Too many open files

> I realized that sox was catenating all the files in the
> directory, and then giving the stats for the final one BIG
> file.

I don't know enough about DOS to help with a MSWin native command -
but for bash, here is a one-liner script using bash and grep.
This will show the name of each file and it's Max amplitude value.

for i in *.wav; do echo -n "$i "; sox "$i" -n stat 2>&1 | grep "Maximum amplitude"; done

Or, doing a bit more, but making it longer than I like fitting
into one line.   This depends on grep and bc.  This one will
output to the screen a list of the filenames and Max amplitude
value of _only_ the files with a Max amplitude less than the set
variable.  The file it generates will be filename only of those
quiet files.

<---------------------------------------->
#!/bin/bash
##  A quick hack like script to list all the files that have
## a low amplitude.
##
##  Input is a bash file list or glob.  
##
##  $ scrip.bash *.wav
##
## Each time the script runs it will remove the output list
## and regenerate it.  Stderr will output each file and it's
## amplitude.  

Max=0.1  # Any amplitude greater than this will NOT be listed
OutList=output.list # The name of the file that contains a
                    # list of file names only of all the
                    # low-amplitude files.

rm $OutList
for each in "$@"
do amplitude=$(sox "$each" -n stat 2>&1 | grep "Maximum amplitude" | cut -d ":" -f 2 | sed 's/ //g')
   if [[ $(echo "if (${amplitude} > ${Max}) 1 else 0" | bc) -eq 0 ]]
       then echo "$each  -->  $amplitude" >&2
       echo "$each" >> $OutList
   fi
done

<----------------------------------------->


--    Philip

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

phofman
In reply to this post by Teledon


Dne 26.12.2011 16:41, Teledon napsal(a):

> I am working with 25,000 audio files. A few of these files are
> completely silent. Some have very soft noises. I want to find all the
> files which never get louder than some specified level, The goal is to
> find and remove all the files with no or minimal audio in them.
>
> In the best case, I would like to produce a list of the file names of
> all the quiet files in a text file. I am using Win7, so a Win7 command
> line would be the best for me. I also have a new MacBook Pro, so I could
> use a linux bash command line script in a pinch, but I would have to
> move all the 25K files over to the Mac.

I find cygwin a treat for these unlucky moments when windows must be
used. Bash scripting, useful unix tools, ...

Regards,

Pavel.

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Hannu Vuolasaho

cmd.exe has for loop
http://www.jamesewelch.com/2008/05/01/how-to-write-a-dos-batch-file-to-loop-through-files/

for /f %%a IN ('dir /b *.wav') do sox --stat %%a >>statfile.txt
from there I don't know. findstr is for grep but I couldn't find anything useful for cut or sed.
But if you findstr the Maximum aplitude and import to excel as CSV with space delimiter and sort by the max amplitude, delete unwanted rows and everything except filename and save as CSV again it could be freed to for loop again.

Yes. It's huge hassle but those are tools given by MS :D

Hannu Vuolasaho

     
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Doug Cook-2
Windows CMD scripting is weird, but it is adequante for most tasks. If
you need something more powerful, there's always PowerShell. The only
problem with either of these is that the syntax is not
bash-compatible. They aren't bad, just different.

You only want double-% if you are using a for loop within a bat file.
You don't need double-% when writing a for loop at the command line.
Here is how I would do it at the command line:

for %a in (*.wav) do @echo %a&&( sox --stat "%a" 2>nul | findstr
/c:"Maximum amplitude")

Within a bat file, you would have to double each of the % characters.

On Mon, Dec 26, 2011 at 1:58 PM, Hannu Vuolasaho <[hidden email]> wrote:

>
> cmd.exe has for loop
> http://www.jamesewelch.com/2008/05/01/how-to-write-a-dos-batch-file-to-loop-through-files/
>
> for /f %%a IN ('dir /b *.wav') do sox --stat %%a >>statfile.txt
> from there I don't know. findstr is for grep but I couldn't find anything useful for cut or sed.
> But if you findstr the Maximum aplitude and import to excel as CSV with space delimiter and sort by the max amplitude, delete unwanted rows and everything except filename and save as CSV again it could be freed to for loop again.
>
> Yes. It's huge hassle but those are tools given by MS :D
>
> Hannu Vuolasaho
>
>
> ------------------------------------------------------------------------------
> Write once. Port to many.
> Get the SDK and tools to simplify cross-platform app development. Create
> new or port existing apps to sell to consumers worldwide. Explore the
> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
> http://p.sf.net/sfu/intel-appdev
> _______________________________________________
> Sox-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sox-users

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Teledon
In reply to this post by phofman
I'm having problems running sox. I put sox in the local directory, but when I try to execute it, I get:
-bash: sox: command not found

I have double-checked that sox is in the local directory. The file doesn't show any extension in OSX finder, but the icon is dark. I suspect some permissions need to be set, but i have no clue how to do that.

Teledon

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

hendrikus godvliet
<I'm having problems running sox. I put sox in the local directory, but when I try to execute it, I get:  -bash: sox: command not found

To install Sox in Os X this is what I found:
wget http://kent.dl.sourceforge.net/sourceforge/sox/sox-14.3.2.tar.gz
tar xzvf sox-14.3.2.tar.gz
cd sox-13.0.0
./configure
make
sudo make install






------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

hendrikus godvliet
In reply to this post by Teledon
MUST BE!

<I'm having problems running sox. I put sox in the local directory, but when I try to execute it, I get:  -bash: sox: command not found

To install Sox in Os X this is what I found:
wget http://kent.dl.sourceforge.net/sourceforge/sox/sox-14.3.2.tar.gz
tar xzvf sox-14.3.2.tar.gz
cd sox-14.3.2
./configure
make
sudo make install





------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

phofman
In reply to this post by Teledon

Dne 27.12.2011 04:55, Teledon napsal(a):
> I'm having problems running sox. I put sox in the local directory, but
> when I try to execute it, I get:
> -bash: sox: command not found
>
> I have double-checked that sox is in the local directory. The file
> doesn't show any extension in OSX finder, but the icon is dark. I
> suspect some permissions need to be set, but i have no clue how to do that.
>

In unix shells, you either have to specify path to your executable file,
or have the file's directory in your PATH variable. In this particular
case your sox binary should be called ./sox, since path "./" means
current directory.

Regards,

Pavel.

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Running SoX on a Mac. was: Finding Silent Files

Fmiser
In reply to this post by Teledon
> Teledon wrote:

> I'm having problems running sox. I put sox in the local
> directory, but when I try to execute it, I get:
> -bash: sox: command not found

Try "./sox" rather than "sox".  Yes, current directory is
presumed, but for execution it has to be deliberately
specified.  "./" at the front makes it clear.

> I have double-checked that sox is in the local directory. The
> file doesn't show any extension in OSX finder, but the icon is
> dark. I suspect some permissions need to be set, but i have no
> clue how to do that.

>From the GUI, I think it's right click and get properties.  Or
maybe it's called information.  I think Command-i is the
keyboard shortcut.  In the window that opens, there is a section
called "permissions" where you can choose who can read, write,
or execute.

Note: this is based on my memory using OS 10.2.  Things might
have changed.

--   Philip

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Teledon
In reply to this post by phofman
Pavel,

Thanks much. The ./ fixed the problem I was having with running my scripts locally. Now, if I wanted to put the sox executable in the system path, where is the standard location for global exe's in Mac OSx? And how do you set the system path to the sox exe, once it is in the standard location? (I'm a Windows user primarily, so I'm still figuring out Linux).

Also I want to thank Phillip for his nice one-liner for bash/OSx:
for i in *.wav; do echo -n "$i "; sox "$i" -n stat 2>&1 | grep "Maximum amplitude"; done
That worked perfectly, once I figured out the local exe issue. I had to format an external drive to FAT32, and put my 25K audio files from Win7 on it. Then I could run bash on the Mac OS, and process all the files.

The attemptsto write a script for Win7 mostly had a problem due to the lack of a true equivalent to grep in bash.

Teledon

On Tue, Dec 27, 2011 at 3:41 AM, Pavel Hofman <[hidden email]> wrote:

Dne 27.12.2011 04:55, Teledon napsal(a):
> I'm having problems running sox. I put sox in the local directory, but
> when I try to execute it, I get:
> -bash: sox: command not found
>
> I have double-checked that sox is in the local directory. The file
> doesn't show any extension in OSX finder, but the icon is dark. I
> suspect some permissions need to be set, but i have no clue how to do that.
>

In unix shells, you either have to specify path to your executable file,
or have the file's directory in your PATH variable. In this particular
case your sox binary should be called ./sox, since path "./" means
current directory.

Regards,

Pavel.


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Pascal Giard
Hi Teledon,
While you have solved your problem, in case you might need grep under windows in the future, you should have a look at the gnuwin32 website. There very useful utilities such as grep [1].

-Pascal

Le 2011-12-27 à 13:51, Teledon <[hidden email]> a écrit :

Pavel,

Thanks much. The ./ fixed the problem I was having with running my scripts locally. Now, if I wanted to put the sox executable in the system path, where is the standard location for global exe's in Mac OSx? And how do you set the system path to the sox exe, once it is in the standard location? (I'm a Windows user primarily, so I'm still figuring out Linux).

Also I want to thank Phillip for his nice one-liner for bash/OSx:
for i in *.wav; do echo -n "$i "; sox "$i" -n stat 2>&1 | grep "Maximum amplitude"; done
That worked perfectly, once I figured out the local exe issue. I had to format an external drive to FAT32, and put my 25K audio files from Win7 on it. Then I could run bash on the Mac OS, and process all the files.

The attemptsto write a script for Win7 mostly had a problem due to the lack of a true equivalent to grep in bash.

Teledon

On Tue, Dec 27, 2011 at 3:41 AM, Pavel Hofman <[hidden email]> wrote:

Dne 27.12.2011 04:55, Teledon napsal(a):
> I'm having problems running sox. I put sox in the local directory, but
> when I try to execute it, I get:
> -bash: sox: command not found
>
> I have double-checked that sox is in the local directory. The file
> doesn't show any extension in OSX finder, but the icon is dark. I
> suspect some permissions need to be set, but i have no clue how to do that.
>

In unix shells, you either have to specify path to your executable file,
or have the file's directory in your PATH variable. In this particular
case your sox binary should be called ./sox, since path "./" means
current directory.

Regards,

Pavel.

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Teledon
In reply to this post by Teledon
I would like to capture three stats values from each of the audio files. The length, the Max amplitude, and the RMS amplitude.

The following siltest3.sh script does most of the work:

for i in *.wav 
do echo -n "$i "; ./sox "$i" -n stat 2>&1 | egrep 'Length|Maximum amplitude|RMS     amplitude' | cut -d ":" -f 2 | sed 's/ //g'
done

However, the output has line feeds in it:

new-host-4:ASr8s teledon$ ./siltest3.sh
gr20111029post-24161.wav 2.840000
0.980347
0.122100
gr20111029post-24162.wav 2.900000
0.855347
0.131837
gr20111029post-24163.wav 1.500000
0.980347
0.121265
gr20111029post-24164.wav 2.400000
0.980347
0.154356
gr20111029post-24165.wav 1.479750
0.410034
0.062767
gr20111029post-24166.wav 1.959750
0.917847
0.146649

How can I get rid of the line feeds so the result looks like this:

new-host-4:ASr8s teledon$ ./siltest3.sh
gr20111029post-24161.wav 2.840000  0.980347 0.122100
gr20111029post-24162.wav 2.900000 0.855347 0.131837
gr20111029post-24163.wav 1.500000 0.980347 0.121265
gr20111029post-24164.wav 2.400000 0.980347 0.154356
gr20111029post-24165.wav 1.479750 0.410034 0.062767
gr20111029post-24166.wav 1.959750 0.917847 0.146649

Teledon



------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

Jan Stary
On Dec 28 13:23:24, Teledon wrote:

> I would like to capture three stats values from each of the audio files.
> The length, the Max amplitude, and the RMS amplitude.
>
> The following siltest3.sh script does most of the work:
>
> for i in *.wav
> do echo -n "$i "; ./sox "$i" -n stat 2>&1 | egrep 'Length|Maximum
> amplitude|RMS     amplitude' | cut -d ":" -f 2 | sed 's/ //g'
> done
>
> However, the output has line feeds in it:
>
> new-host-4:ASr8s teledon$ ./siltest3.sh
> gr20111029post-24161.wav 2.840000
> 0.980347
> 0.122100
> gr20111029post-24162.wav 2.900000
> 0.855347
> 0.131837
> gr20111029post-24163.wav 1.500000
> 0.980347
> 0.121265
> gr20111029post-24164.wav 2.400000
> 0.980347
> 0.154356
> gr20111029post-24165.wav 1.479750
> 0.410034
> 0.062767
> gr20111029post-24166.wav 1.959750
> 0.917847
> 0.146649
>
> How can I get rid of the line feeds so the result looks like this:
>
> new-host-4:ASr8s teledon$ ./siltest3.sh
> gr20111029post-24161.wav 2.840000  0.980347 0.122100
> gr20111029post-24162.wav 2.900000 0.855347 0.131837
> gr20111029post-24163.wav 1.500000 0.980347 0.121265
> gr20111029post-24164.wav 2.400000 0.980347 0.154356
> gr20111029post-24165.wav 1.479750 0.410034 0.062767
> gr20111029post-24166.wav 1.959750 0.917847 0.146649

Again, this is a scripting excercise that has nothing
to do with SoX. Please take this elsewhere.

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Finding Silent Files

dathead2
In reply to this post by Teledon
this may not be the best way but I do it via:
  echo $(./sox then-the-rest-of-your-command)
this also has by-product of getting rid of extra white-space

> The following siltest3.sh script does most of the work:
>
> for i in *.wav
> do echo -n "$i "; ./sox "$i" -n stat 2>&1 | egrep 'Length|Maximum
> amplitude|RMS     amplitude' | cut -d ":" -f 2 | sed 's/ //g'
> done

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users