Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/bash
- # -----------------
- # Global Vars.
- last_command="null"
- time_function="0"
- focus=0
- # ------------------
- # =========================
- # ------------------
- # Init pocketsphinx
- ./record.sh
- sleep 2
- # ------------------
- while [[ true ]] ; do
- # Speech-to-text Primer
- command=$(tail -1 words.txt | head -1 | cut -c 3-)
- # Commands
- if [[ $focus -gt 0 ]] && [[ $command != $last_command ]] ; then
- # Feelings
- if [[ $command == *"how"* ]] && [[ $command == *"feeling"* ]] ; then
- espeak -a 400 -s 120 -v en-sc+f5 "i'm doing okay. thank you"
- elif [[ $command == *"thank you"* ]] ; then
- espeak -a 400 -s 170 -v en-sc+f5 "you are quite welcome"
- # Turn off the program
- elif [[ $command == *"shut down"* ]] || [[ $last_comamand == *"shut down"* ]]; then
- if [[ $command == *"yes"* ]] ; then
- espeak -a 400 -s 155 -v en-sc+f5 "very well. i'm shutting down now"
- exit 1;
- else
- espeak -a 400 -s 155 -v en-sc+f5 "do you want me to shut down, sir?"
- fi
- # Get IP address
- elif [[ $command == *"what is"* ]] && [[ $command == *"address"* ]] ; then
- getIP=$(curl -s icanhazip.com)
- espeak -a 400 -s 130 -v en-sc+f5 "Your I P address is $getIP"
- # Google Search function
- elif [[ $command == *"search"* ]] ; then
- searchterm=$(echo $command | cut -d' ' -f2- | sed -e 's/\ /+/g')
- espeak -a 400 -s 175 -v en-sc+f5 "let me try to find something"
- info=$(lynx -dump http://www.google.com/search?q=$searchterm | less | grep -A2 'Wikipedia' | grep -v "Wikipedia" | grep -v -E "^$")
- speak=$(espeak -a 400 -s 165 -v en-sc+f5 "$info")
- # Start/Stop Services
- elif [[ $command == *"start"* ]] || [[ $command == *"stop"* ]] ; then
- if [[ $command == *"time recording"* ]] && [[ $command == *"start"* ]] ; then
- time_function="1"
- speak=$(espeak -a 400 -s 165 -v en-sc+f5 "Time recording is on")
- else
- time_function="0"
- speak=$(espeak -a 400 -s 165 -v en-sc+f5 "Time recording is off")
- fi
- # Violin tuner
- elif [[ $command == *"play"* ]] && [[ $command == *"music"* ]] ; then
- espeak -a 400 -s 155 -v en-sc+f5 "Playing violin notes now"
- playG=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/G-0.mp3')
- playD=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/D-0.mp3')
- playA=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/A-0.mp3')
- playE=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/E-0.mp3')
- fi
- ((focus--))
- fi
- # Activation
- if [[ $command == *"computer"* ]] && [[ $last_command != $command ]] ; then
- espeak -a 400 -s 155 -v en-sc+f5 "yes?"
- focus=30
- fi
- # Time functions
- if [[ $time_function == '1' ]] ; then
- H=$(date +%H)
- M=$(date +%M)
- S=$(date +%S)
- if [[ $H == 23 ]] && [[ $M == 59 ]] && [[ $S == 59 ]] ; then
- espeak -a 400 -s 155 -v en-sc+f5 "it is fucking midnight. go to sleep"
- fi
- fi
- # Delay and tailer
- #echo $command
- last_command=$command
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement