Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. #!/usr/local/bin/bash
  2.  
  3. # -----------------
  4. # Global Vars.
  5. last_command="null"
  6. time_function="0"
  7. focus=0
  8. # ------------------
  9. # =========================
  10. # ------------------
  11. # Init pocketsphinx
  12. ./record.sh
  13. sleep 2
  14. # ------------------
  15.  
  16. while [[ true ]] ; do
  17.  
  18. # Speech-to-text Primer
  19. command=$(tail -1 words.txt | head -1 | cut -c 3-)
  20.  
  21. # Commands
  22. if [[ $focus -gt 0 ]] && [[ $command != $last_command ]] ; then
  23. # Feelings
  24. if [[ $command == *"how"* ]] && [[ $command == *"feeling"* ]] ; then
  25. espeak -a 400 -s 120 -v en-sc+f5 "i'm doing okay. thank you"
  26. elif [[ $command == *"thank you"* ]] ; then
  27. espeak -a 400 -s 170 -v en-sc+f5 "you are quite welcome"
  28. # Turn off the program
  29. elif [[ $command == *"shut down"* ]] || [[ $last_comamand == *"shut down"* ]]; then
  30. if [[ $command == *"yes"* ]] ; then
  31. espeak -a 400 -s 155 -v en-sc+f5 "very well. i'm shutting down now"
  32. exit 1;
  33. else
  34. espeak -a 400 -s 155 -v en-sc+f5 "do you want me to shut down, sir?"
  35. fi
  36. # Get IP address
  37. elif [[ $command == *"what is"* ]] && [[ $command == *"address"* ]] ; then
  38. getIP=$(curl -s icanhazip.com)
  39. espeak -a 400 -s 130 -v en-sc+f5 "Your I P address is $getIP"
  40. # Google Search function
  41. elif [[ $command == *"search"* ]] ; then
  42. searchterm=$(echo $command | cut -d' ' -f2- | sed -e 's/\ /+/g')
  43. espeak -a 400 -s 175 -v en-sc+f5 "let me try to find something"
  44. info=$(lynx -dump http://www.google.com/search?q=$searchterm | less | grep -A2 'Wikipedia' | grep -v "Wikipedia" | grep -v -E "^$")
  45. speak=$(espeak -a 400 -s 165 -v en-sc+f5 "$info")
  46. # Start/Stop Services
  47. elif [[ $command == *"start"* ]] || [[ $command == *"stop"* ]] ; then
  48. if [[ $command == *"time recording"* ]] && [[ $command == *"start"* ]] ; then
  49. time_function="1"
  50. speak=$(espeak -a 400 -s 165 -v en-sc+f5 "Time recording is on")
  51. else
  52. time_function="0"
  53. speak=$(espeak -a 400 -s 165 -v en-sc+f5 "Time recording is off")
  54. fi
  55. # Violin tuner
  56. elif [[ $command == *"play"* ]] && [[ $command == *"music"* ]] ; then
  57. espeak -a 400 -s 155 -v en-sc+f5 "Playing violin notes now"
  58. playG=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/G-0.mp3')
  59. playD=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/D-0.mp3')
  60. playA=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/A-0.mp3')
  61. playE=$(su - synja -c 'vlc --stop-time 6 --play-and-exit sysmon/music/E-0.mp3')
  62. fi
  63.  
  64. ((focus--))
  65. fi
  66.  
  67.  
  68. # Activation
  69. if [[ $command == *"computer"* ]] && [[ $last_command != $command ]] ; then
  70. espeak -a 400 -s 155 -v en-sc+f5 "yes?"
  71. focus=30
  72. fi
  73.  
  74. # Time functions
  75. if [[ $time_function == '1' ]] ; then
  76. H=$(date +%H)
  77. M=$(date +%M)
  78. S=$(date +%S)
  79.  
  80. if [[ $H == 23 ]] && [[ $M == 59 ]] && [[ $S == 59 ]] ; then
  81. espeak -a 400 -s 155 -v en-sc+f5 "it is fucking midnight. go to sleep"
  82. fi
  83. fi
  84.  
  85. # Delay and tailer
  86. #echo $command
  87. last_command=$command
  88. sleep 1
  89.  
  90. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement