Announcement

Collapse
No announcement yet.

How To use Google voice for text-to-speech on Zee and Linux

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How To use Google voice for text-to-speech on Zee and Linux

    Note: This no longer works, read down to find an alternate solution

    The following applies to the HomeTroller Zee (S1 or S2) the SEL, or Linux HS3.

    This procedure assumes that you know how to SSH to your controller and access the command prompt.

    The TTS on Linux is not very good, but there is a way to have your text converted to speech using Google. The TTS is converted using a script called speak_to_file.sh in the HS folder (/usr/local/HomeSeer)

    The result is the text will be spoken with the same voice that used on Android.

    This requires the mpg123 medial player, so install that first with the command:

    sudo apt-get install mpg123

    Replace that file contents this:

    Code:
    #!/bin/bash
    #################################
    # Speech Script by Dan Fountain #
    #      TalkToDanF@gmail.com     #
    #################################
     
     
    INPUT=$2
    STRINGNUM=0
     
    ary=($INPUT)
    echo "---------------------------"
    echo "Speech Script by Dan Fountain"
    echo "TalkToDanF@gmail.com"
    echo "---------------------------"
    for key in "${!ary[@]}" 
      do
        SHORTTMP[$STRINGNUM]="${SHORTTMP[$STRINGNUM]} ${ary[$key]}"
        LENGTH=$(echo ${#SHORTTMP[$STRINGNUM]})
        #echo "word:$key, ${ary[$key]}"
        #echo "adding to: $STRINGNUM"
        if [[ "$LENGTH" -lt "100" ]]; then
          #echo starting new line
          SHORT[$STRINGNUM]=${SHORTTMP[$STRINGNUM]}
        else
          STRINGNUM=$(($STRINGNUM+1))
          SHORTTMP[$STRINGNUM]="${ary[$key]}"
          SHORT[$STRINGNUM]="${ary[$key]}"
        fi
    done
     
    for key in "${!SHORT[@]}"
      do
        #echo "line: $key is: ${SHORT[$key]}"
     
        echo "Playing line: $(($key+1)) of $(($STRINGNUM+1))"
        NEXTURL=$(echo ${SHORT[$key]} | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
        mpg123 -w $1 -q "http://translate.google.com/translate_tts?tl=en&q=$NEXTURL"
    done
    The above script was modified from this one:

    http://danfountain.com/2013/03/raspb...ext-to-speech/
    Last edited by rjh; March 30, 2016, 05:52 PM.
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    #2
    I'm getting:
    -bash: mpg123: command not found

    This is on HS3 Linux on a Rpi2.
    What packages are required for mpg123?
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android

    Comment


      #3
      Install mpg123 with:

      sudo apt-get install mpg123

      Originally posted by rmasonjr View Post
      I'm getting:
      -bash: mpg123: command not found

      This is on HS3 Linux on a Rpi2.
      What packages are required for mpg123?
      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

      Comment


        #4
        oh wow! Rich, that sounds so much better than the original voice! Many thanks!
        HS4Pro on a Raspberry Pi4
        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

        HSTouch Clients: 1 Android

        Comment


          #5
          does this hack still work for anyone?
          I'm getting "HTTP request failed: 503 Service Unavailable", and if I paste the google url in a browser I first get a captcha.

          Comment


            #6
            Mine was working last night - I get TTS on outside motion. I'll test it tonight and see...
            HS4Pro on a Raspberry Pi4
            54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
            Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

            HSTouch Clients: 1 Android

            Comment


              #7
              Right, looks like they added a captcha to the page, so I guess this won't work anymore. If you enter the text, it does start working without a prompt, but I'm not sure if its verifying the IP, or maybe there is a timeout, so it may not work for very long.

              Originally posted by spud View Post
              does this hack still work for anyone?
              I'm getting "HTTP request failed: 503 Service Unavailable", and if I paste the google url in a browser I first get a captcha.
              💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

              Comment


                #8
                Thats a shame. The quality of the Google TTS was very good
                HS4Pro on a Raspberry Pi4
                54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                HSTouch Clients: 1 Android

                Comment


                  #9
                  Alternate script for text-to-speech

                  A user has modified the script to use voice RSS, pretty good voices.

                  You will need your own API key for this to work, and edit the script by inserting your key into the second to last line.

                  Code:
                  #!/bin/bash
                  #################################
                  # Speech Script by Dan Fountain #
                  #      TalkToDanF@gmail.com     #
                  #################################
                   
                   
                  INPUT=$2
                  STRINGNUM=0
                   
                  ary=($INPUT)
                  echo "---------------------------"
                  echo "Speech Script by Dan Fountain"
                  echo "TalkToDanF@gmail.com"
                  echo "---------------------------"
                  for key in "${!ary[@]}" 
                    do
                      SHORTTMP[$STRINGNUM]="${SHORTTMP[$STRINGNUM]} ${ary[$key]}"
                      LENGTH=$(echo ${#SHORTTMP[$STRINGNUM]})
                      #echo "word:$key, ${ary[$key]}"
                      #echo "adding to: $STRINGNUM"
                      if [[ "$LENGTH" -lt "100" ]]; then
                        #echo starting new line
                        SHORT[$STRINGNUM]=${SHORTTMP[$STRINGNUM]}
                      else
                        STRINGNUM=$(($STRINGNUM+1))
                        SHORTTMP[$STRINGNUM]="${ary[$key]}"
                        SHORT[$STRINGNUM]="${ary[$key]}"
                      fi
                  done
                   
                  for key in "${!SHORT[@]}"
                    do
                      #echo "line: $key is: ${SHORT[$key]}"
                   
                      echo "Playing line: $(($key+1)) of $(($STRINGNUM+1))"
                      NEXTURL=$(echo ${SHORT[$key]} | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
                  	mpg123 -w $1 -q "http://api.voicerss.org/?key=Your_API_Key&f=48khz_8bit_stereo&hl=en-gb&src=$NEXTURL"
                  done
                  Last edited by rjh; March 30, 2016, 05:54 PM.
                  💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                  Comment


                    #10
                    Sounds pretty good - see attached...
                    Attached Files
                    HS4Pro on a Raspberry Pi4
                    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                    HSTouch Clients: 1 Android

                    Comment

                    Working...
                    X