How to use Vox for basic system function,remote VNC Raspberry Pi login and others ( Vox part 2 script)




 This post show How to use Vox for controlling system basic function using voice recognition .It is a continuity from my previous post    .At this moment, The program consist of 3 main script.There will be  a more function added to this program in the future .

Script

1.vox (main script)
2.vrec (recording script. will use more for future development)
3.vsort ( return text integrate with local system script )


Script details

1.Vox script(main script)



1.1.Variable declaration and changing directory working directory to ~/vox-master .

URL="http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium&maxresults=10" 


 cd ~/vox-master

If you use different language than english, you need to  change "en-us" in the above script..Check here for language reference. Notice the "&maxresults=10" line . What this line do is, it request for maximum 10 results from Google server.


1.2. Calling the recording program.

./vrec

Currently, the program can only record for 3 seconds  .You can remove this line and just  use          " rec -r 16000 -b 16 voice.flac trim 0 3 " instead .The recorded file will be save as "voice.flac"

1.3 "voice.flac" will then be send over to Google voice search engine and it will feedback a text message to our system . The retrieve result from Google is then pipe into a file call "result" .I use "result" information  to custom  my "vsort"file .

wget -q -U "Ninetailfox" --post-file voice.flac --header "Content-Type: audio/x-flac; rate=16000" -O - "$URL" >result

The detail information of the above command is much more easier to understand with snapshot from Wireshark . Click here to download vox wireshark file .

Vox Wireshark snapshot



1.4 Sorting out the return result and send it over to "vsort" script. After vsort file being execute, The program will wait for 5 second delay before executing .


RETURN="$(cat result | cut -d\" -f12 )"
echo "you said :$RETURN"
./vsort "$RETURN"
sleep 5

2 Vrec script .
At this moment, Vrec only consist of one line .I'll be using this file more in the future development.


3.Vsort script


What this script does is it associate the word that has been retrieve from Google server and use it to execute a command  that is associated with your system. You need to make sure what kind of word is use and what command you want  to execute . You need to edit this file to make it work with your system.



In the existing script ,

case "$1" in
 'ping server') 
 cd /home/shark_attack/Programming/bash
 ./pi -ping 
 ;;

'ping server' is the word I choose and I want it to execute my "./pi" script  in  "/home/shark_attack/Programming/bash" . Click here to check my previous post on my pi script .

I will update more function on vox in the future . At the moment, I'm testing some other stuff and playing around with some code. That's it for now.Please leave comment on the box below .