Ubuntu: arecord flac format



Question:

I am playing with scripts that use the google speech-to-text api. The api requires flac encoded files so the recording part of the script looks like this:

arecord -q -t wav -d 0 -f S16_LE -r 16000 | flac - -f --best --sample-rate 16000 -s -o "$TEMP_FILE"  

This command will record until the user exits with ctrl-c and the wav recorded format should be piped to the flac program for outut in flac format, then the script should continue.

The problem I am having is that pressing ctrl-c ends the script entirely and is cutting off some of the audio (the flac file is still outputted). If I run the script without the pipe:

arecord -q -t wav -d 0 -f S16_LE -r 16000 some.wav  

Then pressing ctrl-c will only ends the recording and continues on with the script as it should.

How do I fix this so that ctrl-c only stops the arecord command and allows the rest of the script (including the piped flac encoding) to finish?


Solution:1

The arecord command has the -d argument to time it out with this modification the arecord command will time out but not the FLAC.

arecord -q -t wav -d 4 -f S16_LE -r 16000 | flac - -f --best --sample-rate 16000 -s -o "$TEMP_FILE"  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »