Guest User

speech.sh

a guest
Mar 6th, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.46 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Добавить в запускаемые приложения: /home/user/run_speech.sh /home/user/speech.sh
  4.  
  5. COMMAND_COUNTER=0
  6. MESSAGE_HEADER=""
  7. MESSAGE_BODY=""
  8. PARSE_REQUIRED=0
  9.  
  10. while read -r DBUS_MESSAGE ; do
  11.         ID=`echo $DBUS_MESSAGE | grep "uint32 0"`
  12.  
  13.         if [[ $ID ]] ; then
  14.                 let COMMAND_COUNTER=0
  15.                 let PARSE_REQUIRED=1
  16.         else
  17.                 if [ $PARSE_REQUIRED -eq 1 ] ; then
  18.                         ID=`echo $DBUS_MESSAGE | egrep "string\ \""`
  19.  
  20.                         if [[ $ID ]] ; then
  21.                                 let COMMAND_COUNTER=$COMMAND_COUNTER+1
  22.                         fi                                                                    
  23.  
  24.                         if [ $COMMAND_COUNTER -eq 2 ] ; then
  25.                                 MESSAGE_HEADER=`echo $DBUS_MESSAGE | grep "string\ \"" | sed s/^string\ \"//g | sed s/\"$//g`
  26.                         fi
  27.  
  28.                         if [ $COMMAND_COUNTER -eq 3 ] ; then
  29.                                 MESSAGE_BODY=`echo $DBUS_MESSAGE | grep "string\ \"" | sed s/^string\ \"//g | sed s/\"$//g`
  30.  
  31.                                echo $MESSAGE_HEADER | festival --tts
  32.                                 echo $MESSAGE_BODY | festival --tts
  33.  
  34.                                 let COMMAND_COUNTER=$COMMAND_COUNTER+1
  35.                                 let PARSE_REQUIRED=0
  36.                         fi
  37.                 fi
  38.         fi
  39. done
Advertisement
Add Comment
Please, Sign In to add comment