Created
April 19, 2016 16:51
-
-
Save saikrishna321/833e0206741dbe5f8caff7036d58b090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
hardware="plughw:1,0" | |
duration="3" | |
lang="en" | |
hw_bool=0 | |
dur_bool=0 | |
lang_bool=0 | |
for var in "$@" | |
do | |
if [ "$var" == "-D" ] ; then | |
hw_bool=1 | |
elif [ "$var" == "-d" ] ; then | |
dur_bool=1 | |
elif [ "$var" == "-l" ] ; then | |
lang_bool=1 | |
elif [ $hw_bool == 1 ] ; then | |
hw_bool=0 | |
hardware="$var" | |
elif [ $dur_bool == 1 ] ; then | |
dur_bool=0 | |
duration="$var" | |
elif [ $lang_bool == 1 ] ; then | |
lang_bool=0 | |
lang="$var" | |
else | |
echo "Invalid option, valid options are -D for hardware and -d for duration" | |
fi | |
done | |
#this works really inconsistently and I don't know why. I would love to implement it | |
#sox -r 16000 -t alsa $hardware /dev/shm/out.flac silence 1 0.3 1% 1 0.5 1% | |
#wget -q -U "rate=16000" -O - --post-file /dev/shm/out.flac --header="Content-Type: audio/x-flac; rate=16000" "http://www.google.com/speech-api/v1/recognize?lang=en&client=Mozil$ | |
#arecord -D $hardware -f cd -t wav -d $duration -r 16000 | flac - -f --best --sample-rate 16000 -o /dev/shm/out.flac 1>/dev/shm/voice.log 2>/dev/shm/voice.log; wget -O - -o /dev$ | |
arecord -D $hardware -f cd -t wav -d $duration -r 16000 | flac - -f --best --sample-rate 16000 -o /dev/shm/out.flac 1>/dev/shm/voice.log 2>/dev/shm/voice.log; curl -X POST --dat$ | |
rm /dev/shm/out.flac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(line 35)
arecord -D $hardware -f cd -t wav -d $duration -r 16000 ...
Google Speech API has changed and no longer accepts multi-channel audio (based on my research. Actual reason may be different.) Follow instructions in #55 on how to update that line (and lines in other files) to use the new google acceptable audio format.