Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #######################################################################
- #Artificial intelligence, voice recognition using Google.
- #Inteligencia artificial con reconocimiento de voz usando Google.
- #Искусственный интеллект, распознавание голоса с помощью Google.
- #Script creado por Alexis Zaytsev (alexiszaytsev@gmail.com)
- #######################################################################
- #Antes de ejecutar el script hay que instalar dependencias.
- #sudo apt-get install alsa-utils
- #sudo apt-get install sox
- ##sudo apt-get install espeak
- #######################################################################
- # LICENCIA DE USO
- #######################################################################
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see «http://www.gnu.org/licenses/».
- #######################################################################
- echo "grabando..."
- arecord -D plughw:1,0 -d 3 -q -f cd -r 16000 speech.wav # Grabamos audio file speech.wav de 03 segundos сon 16 мГц samping rate.
- echo "grabacion finalizada"
- sox speech.wav speech.flac gain -n -5 silence 1 5 2% # Conversión de formato speech.wav en speech.flac
- rm speech.wav # Eliminamos speech.wav
- echo "analisis de voz..."
- wget -q -U "Mozilla/5.0" --post-file speech.flac --header="Content-Type: audio/x-flac; rate=16000" -O - "https://www.google.com/speech-api/v2/recognize?output=json&lang=es-ES&key=AIzaSyAqk7vE0vQDR3JItUPgFp6bcPqgJz8h8tI" | cut -d\" -f8 > text.txt
- rm speech.flac # Eliminamos speech.flac
- file="/home/tu_nombre/text.txt" #La ruta donde se encuentra el archivo text.txt
- read -d $'\x04' name < "$file" #El contenido de $ archivo se redirige a la entrada estándar desde donde se lee en la variable $ name
- case $name in #Ponemos los parametros para buscar y comparar las palabras.
- "Hola") echo "Hola!!! Que tal!" | espeak -v es-la -s 160
- ;;
- "hola qué tal") echo "Hola!!! Que tal!" | espeak -v es-la -s 160
- ;;
- "qué tal") echo "Hola!!! Que tal!" | espeak -v es-la -s 160
- ;;
- "ordenador") echo "Si!!! Te escucho!!!" | espeak -v es-la -s 160
- ;;
- "gracias") echo "de nada" | espeak -v es-la -s 160
- ;;
- "muchas gracias") echo "Vale! De nada!" | espeak -v es-la -s 160
- ;;
- "todo bien") echo "Si!!! Todo bien!!!" | espeak -v es-la -s 160
- ;;
- "todo va bien") echo "Si!!! Todo bien!!!" | espeak -v es-la -s 160
- ;;
- "está bien") echo "Si!!! Todo bien!!!" | espeak -v es-la -s 160
- ;;
- "todo está bien") echo "Si!!! Todo bien!!!" | espeak -v es-la -s 160
- ;;
- "quiero decir") echo "Que quieres decirme!!!" | espeak -v es-la -s 160
- ;;
- "quiero decirte") echo "Que quieres decirme!!!" | espeak -v es-la -s 160
- ;;
- "quería decir") echo "Que quieres decirme!!!" | espeak -v es-la -s 160
- ;;
- "quería decirte") echo "Que quieres decirme!!!" | espeak -v es-la -s 160
- ;;
- "qué te quiero") echo "Gracias!!! Yo tambien te quiero!!!" | espeak -v es-la -s 160
- ;;
- "qué te quiero mucho") echo "Gracias!!! Yo tambien te quiero!!!" | espeak -v es-la -s 160
- ;;
- "te quiero mucho") echo "Gracias!!! Yo tambien te quiero!!!" | espeak -v es-la -s 160
- ;;
- esac
Add Comment
Please, Sign In to add comment