Install some necessary packages on Raspberry Pi for Displaying an image and Speech synthesis (Text to Speech). The Festival Speech Synthesis System is a general-purpose multi-lingual speech synthesis system used here. Install Festival Text to Speech by using following commands in LX terminal.
$ sudo apt-get install links2
$ sudo apt-get install mplayer
$ sudo apt-get install festival
$ echo “Hello Robot, How do you do?” | festival
The RPi speaks out “Hello Robot, How do you do?” through speaker connected to the audio jack.
Please find the working code (opti.sh) below–
Copy the shell script to the path:- pocketsphinx-0.8/src/programs/
Shell script (opti.sh)
while [ 0 ]
do
timeout 15 ./pocketsphinx_continuous -adcdev plughw:1 -lm 0092.lm -dict 0092.dic | tee cmd.txt
#run pocketsphinx with your language model file and dictionary file name
head -n 4 cmd.txt | tail -n 1 > cmd1.txt
cut -d ” ” -f 2- cmd1.txt | tee cmd2.txt
case $(tr -d ‘ ‘ <cmd2.txt) in
HELLOROBOT) echo “Hello Everyone, Have a nice day” | –tts ;;
RECORDAUDIO) timeout 10 arecord –D plughw:1,0 sound.wav ;;
#record audio for 10 seconds
PLAYAUDIO) aplay sound.wav ;; #plaing the recorded audio
CAPUTREIMAGE) raspistill –o image.jpg ;; #captures the image file in .jpg format
DISPLAYIMAGE) links2 -g image.jpg ;; #display the image file named image.jpg
*) ;;
esac
done