Recording wav files on Windows 7

I wanted to record sound files quickly on Windows 7, to create some wav files for an IVR application.  Unfortunately, there’s nothing included in Windows 7 that handles it.  Sure, you can install Windows Media Encoder and the like, but that’s cumbersome. And you can record WMA sound files with the windows sound recorder, but then you’ll have to use something like FFmpeg to convert it to a wav file. Too much work.

Sox to the rescue!  Using a simple batch script, I put together a string of sox commands to do what I need:

<span style="color: #0000ff;">@ECHO OFF<br/>
SET PATH=C:UsersPublicDocumentssox-14.4.0;%PATH%<br/>
ECHO %2<br/>
sox -d -r 8000 -c 1 -b 16 "%1.wav" silence 1 0.50 -96d 1 00:03 -96d<br/>
sox "%1.wav" temptrimmed.wav silence 1 00:00:01 -96d<br/>
sox temptrimmed.wav tempreverse.wav reverse<br/>
sox tempreverse.wav temptrimmed.wav silence 1 00:00:01 -96d<br/>
sox temptrimmed.wav "%1.wav" reverse<br/>
del temptrimmed.wav<br/>
del tempreverse.wav</span>

I saved that in a file named soxrecord.cmd

I created another batch file like so:

<span style="color: #0000ff;">soxrecord hello "Hello, and thank you for calling."<br/>
soxrecord unavailable "Unfortunately, the system is currently unavailable."<br/>
soxrecord bye "Good bye!"</span>

I saved that in script.cmd.

I set my headset mic to be the default mic.

Now, when I run script.cmd, I see the text on the screen, and I see sox capturing the mic input.  I speak the phrase and then I hit the mute button on the headset mic (optional).  After 3 seconds, sox stops the recording, trims the beginning and end, and moves on to the next prompt.

That’s it!  Nice and easy.  No need for anything else but sox and a couple of batch files.




Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *