www.homeseer.com    
 

Go Back   HomeSeer Message Board > HomeSeer Products & Services > HomeSeer Software > HS3Touch™

HS3Touch™ Discussions regarding HS3Touch touchscreen software for HomeSeer HS3

Reply
 
Thread Tools Display Modes
  #1  
Old December 24th, 2016, 05:12 PM
DeLicious DeLicious is offline
Seer Deluxe
 
Join Date: Jan 2007
Location: Seattle, WA
Posts: 263
Software Got better voices on HS using AWS Polly

Recently, at Amazon Re:Invent, Amazon made publicly available the voice TTS technology that backs Alexa via Amazon Polly.
See: https://aws.amazon.com/polly/
See: https://aws.amazon.com/blogs/aws/pol...-24-languages/

I was playing around last night with getting HSTouch up and running on both iPhone clients and Android clients while running HSPro on a Raspberry Pi. I was able to eventually get it working with flite, but the voice was pretty bad... like worse than I had 8 years ago running the HS2 speaker client on a Windows tablet. I didn't really want to go that far backward in time.

Then Polly popped in my head, and I thought I'd try to get better voices on HS using some more advanced TTS technology running in the cloud than what I could get with the horsepower available through my RPi.

AWS makes a Python SDK available called boto, and I decided to use the latest boto3. To make this work, you'll need some config files with your AWS access key and secret set up in your home directory as specified in https://github.com/boto/boto3

I then whipped up a quick python script (not anywhere close to my favorite language, and with limited experience, so please take it easy on me!)

Code:
#!/usr/bin/python

import boto3
import sys
import getopt

def main(argv):
        outputfile = ''
        text = ''
        try:
                opts, args = getopt.getopt(argv, "o:t:",["ofile=","text="])
        except getopt.GetoptError:
                print 'polly.py -o  -t '
                sys.exit(2)
        for opt, arg in opts:
                if opt in ("-o", "--ofile"):
                        outputfile = arg
                elif opt in ("-t", "--text"):
                        text = arg
        polly = boto3.client('polly')
        response = polly.synthesize_speech(OutputFormat='mp3', Text=text, VoiceId='Joanna')
        with open(outputfile, 'w') as f:
                for chunk in iter(lambda: response['AudioStream'].read(4096), b''):
                        f.write(chunk)


if __name__ == "__main__":
        main(sys.argv[1:])
I called the resulting file polly.py and copied it to /usr/bin so it would be available on the PATH. Then a quick modification to speak_to_file.sh

Code:
#!/bin/sh -x
#flite -voice slt -o "$1" -t "$2"
polly.py -o "$1" -t "$2"
and now I'm getting Alexa-quality voices through my HSTouch clients. This will probably prompt me to by a few more of the $35 Kindle Fire's and mount them around the house both as touch screens as well as speaker clients with good voice.

Downsides: the latency is a bit higher than before. Ok, whatever. Worse downside is that now I'm relying on internet connection to get announcements instead of rendering everything locally on the Pi. I think for now, that's a trade-off I'm willing to make since up to this point, I haven't really utilized announcements whatsoever.
Reply With Quote
  #2  
Old March 9th, 2017, 03:16 PM
sigbjorn's Avatar
sigbjorn sigbjorn is offline
Seer
 
Join Date: Apr 2003
Location: Norway
Posts: 29
Hi!
I tried your solution, but no luck playing through my Sonos speakers. In my log file, i get the following error:

Error in DoCheckAnnouncementQueue. 100 seconds expired since the announcement started and no end was received.

I have confirmed the wave-file is generated from Polly and stored in the /usr/local/HomeSeer/html/Sonos/Announcements folder.

If I use the original speak_to_file.sh (with flite enabled), the sound is playing.

I also tried running the output to another Speaker client, and it worked.

Any idea?

Regards
Sigbjorn
Reply With Quote
  #3  
Old March 9th, 2017, 03:46 PM
sirmeili sirmeili is online now
Super Seer
 
Join Date: Apr 2015
Location: Sebring, FL
Posts: 1,812
I just saw this. The price is pretty cheap for a single person. I wish they offered some kind of local option (though I'm sure it would cost a lot). I Have a hard time moving stuff like this to the cloud.

It appears to return files, so for announcements, one could cache the files and reuse them instead of always calling the service. For instance my "The Clothe's in the washer are done" announcement could be cached and reused over and over.
__________________
Thanks,
Frank
Reply With Quote
  #4  
Old June 19th, 2018, 09:54 PM
Timon's Avatar
Timon Timon is online now
Seer Deluxe
 
Join Date: Mar 2017
Location: Tustin, CA
Posts: 437
I've been working on how to cache the voice responses so I don't always have to go to Polly. My caching is just about fleshed out and ready to code but I was not sure at all how to access Polly. This python script gives me a good start on fetching the files from Polly.

However, it seems that when running HS3 as a service boto3 can't find its configuration files in the ~/.aws directory, aka, /home/pi/.aws. I finally had to put it in the Polly.py file. That's something that needs to be looked at. So it's up and running and seems to be running quite well. The response time is quite fast. I haven't tried sending the speech through Spud's AirplaySpeak but as soon as I get another RPi I'll check that out.

Anyway, now that's out fo the way what I'm doing is basically taking every speech request that issued from HS3 then checking to see if I've already sent that speech to Polly for conversion. If so then I just return that speech to be vocalized. If it's not found then the translation request will be sent to Polly and when returned it will be saved and then vocalized. The other benefit will be no Internet traffic when the speech is in the cache. This means that you'll still have local speech when the Internet is down.

This should basically reduce the amount of Polly traffic to next to zero. Some traffic will always get through if it contains variable text such as a clock. There are way to reduce most of this but may require some internal modifications to HS3. I'll be trying to find a way so this isn't required.

Once I have this all up and running I'll be releasing it under an Open License.

I'm hoping that HS will take a serious look at this when completed and consider setting up a Polly gateway to Amazon for all registered system to use. Yes, it would cost HS a little money but they already have the Amazon account setup and with the cacheing the extra few $s to support Polly traffic would likely be less that getting a daily coffee for a couple of weeks.

OMT, I will consider allowing a few here that want to try my caching to send requests to my AWS account for a limited time. There is a couple of reasons for this. One to make sure the code is solid and the other to see just how much traffic goes through Polly.
__________________
John (N6BER), Joyce, Lucas (Golden Ret mix), Bella (Great Pyrenees) and Lance (GP).

HomeSeer Version: HS3 Standard 3.0.0.435
Linux version: hs3 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux
Mono version: 5.12.0.226
Z-NET V2 - Version 1.0.23
Number of Devices: 257
Number of Events: 320
Available Threads: 399
HSTouch Enabled: True

3.0.0.13: AirplaySpeak
3.0.0.48: EasyTrigger
3.0.1.109: PHLocation
0.0.0.42: Pushover 3P
3.0.1.190: Z-Wave

Last edited by Timon; June 19th, 2018 at 11:12 PM.
Reply With Quote
  #5  
Old June 21st, 2018, 11:01 AM
Timon's Avatar
Timon Timon is online now
Seer Deluxe
 
Join Date: Mar 2017
Location: Tustin, CA
Posts: 437
I've released my caching PollyC.py3. I'll be releasing the PollyC.py, Python 2 version, shortly. It will automatically handle either plain text or ssml text so you can get better sound voice.

DeLicious, your figuring out how to access Polly was the jump start that got me to write the caching Polly sooner that I had planed. It was the one port of the puzzle I hadn't figured out yet. Please let me know how you want to be credited for your contribution to PollyC. Thanks.

See my Post here.
Reply With Quote
  #6  
Old June 25th, 2018, 02:57 AM
DeLicious DeLicious is offline
Seer Deluxe
 
Join Date: Jan 2007
Location: Seattle, WA
Posts: 263
Great work, Timon! I'm glad somebody had the initiative to pick this up and take it a little bit farther to make it actually functional beyond my plaything
Reply With Quote
  #7  
Old June 25th, 2018, 06:25 PM
Timon's Avatar
Timon Timon is online now
Seer Deluxe
 
Join Date: Mar 2017
Location: Tustin, CA
Posts: 437
Thank you for those kind words.
Reply With Quote
Reply

Bookmarks

Tags
hstouch, polly, tts

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AWS Polly for voices. mrardon HomeSeer Voices 0 November 30th, 2016 07:48 PM
Static voices when switching voices. stevene HomeSeer Voices 0 July 22nd, 2007 08:16 PM
ATT Voices Age? Sky-chan HomeSeer Voices 0 August 1st, 2004 08:31 PM
NeoSpeech and Asian voices / Fun voices GenevaDude HomeSeer Voices 5 December 29th, 2003 08:16 AM


All times are GMT -4. The time now is 11:29 AM.


Copyright HomeSeer Technologies, LLC