34 lines (27 with data), 683 Bytes
#!/bin/bash
cd "$(dirname "$0")"
if [ -e "speech.pid" ];then
read PID_OF_SPEECH < speech.pid
sleep .1 # This is so the end of the speech doesn't get cut off.
kill $PID_OF_SPEECH
./pycmd wait
while kill -s 0 $PID_OF_SPEECH 2>/dev/null;do
:
done
RESULT="$(./recognize)"
# Only takes effect if a script did not use pycmd result
if [ ! -e "UI/result" ];then
./pycmd done
fi
rm -rf speech.pid
else
./pycmd stop
>speech.wav
rec -r 16000 -q -b 16 speech.wav 2>/dev/null &
echo $! > "speech.pid"
# Checks when recording starts
while [ "$(stat -c%s speech.wav)" == "0" ];do
:
done
./pycmd record
fi