Announcement

Collapse
No announcement yet.

Caching Speech routines using Amazon Polly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    TimonDeLicious BTW thanks To Both of you for this amazing script!
    I cheked the price for next year. And this will be almost free..so I do not see what would stop us of using it!.

    Comment


      #17
      Bump: Anyone know how to have the Windows version of hs.speak() go through a speak.sh/bat/vb script just like the Linux version of HS does? Timon ? Thanks!

      Comment


        #18
        Timon I am running this on a x64 ubuntu server. I think both python 3 and 2 are iinstalled.

        python3 script didnt work. ( it says it was missing information in my credentials or something like that.)

        with the exact same setup the python 2 scriipt is working 100%.

        Is there a difference in running v3 vs v2?

        thanks
        Last edited by ; September 21, 2018, 03:24 PM.

        Comment


          #19
          In fact i cheked the python3 script : And this appered in the cli : mandatory option is missing

          It is the line 87 of you script.

          But in python 2 script it works 100 and no problem at all

          Comment


            #20
            There are two scripts, one for python and one for python 2
            HomeSeer Version: HS3 Standard Edition 3.0.0.548
            Linux version: Linux auto 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
            Number of Devices: 484 | Number of Events: 776

            Enabled Plug-Ins: 3.0.0.13: AirplaySpeak | 2.0.61.0: BLBackup
            3.0.0.70: EasyTrigger | 1.3.7006.42100: LiftMaster MyQ
            4.2.3.0: mcsMQTT | 3.0.0.53: PHLocation2 | 0.0.0.47: Pushover 3P
            3.0.0.16: RaspberryIO | 3.0.1.262: Z-Wave

            Z-Net version: 1.0.23 for Inclusion Nodes
            SmartStick+: 6.04 (ZDK 6.81.3) on Server

            Comment


              #21
              Hey Timon is there a way to send TTS off to Polly on Windows? I've used the speak.sh method on linux but I have all of my devices and scripting on my Windows version of HS3 Pro. I know the speaker.exe program will play .mp3 files as easily as .wav, I just need to make the call somehow to Polly and then send the resulting .mp3 to speaker.exe. Can't seem to find any sort of hook to intercept the process once I call hs.speak(). Any help would be awesome!

              Comment


                #22
                My script should work if you have Python loaded on windows.
                HomeSeer Version: HS3 Standard Edition 3.0.0.548
                Linux version: Linux auto 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
                Number of Devices: 484 | Number of Events: 776

                Enabled Plug-Ins: 3.0.0.13: AirplaySpeak | 2.0.61.0: BLBackup
                3.0.0.70: EasyTrigger | 1.3.7006.42100: LiftMaster MyQ
                4.2.3.0: mcsMQTT | 3.0.0.53: PHLocation2 | 0.0.0.47: Pushover 3P
                3.0.0.16: RaspberryIO | 3.0.1.262: Z-Wave

                Z-Net version: 1.0.23 for Inclusion Nodes
                SmartStick+: 6.04 (ZDK 6.81.3) on Server

                Comment


                  #23
                  The python part works great if I use it manually in a DOS window. However, the Windows version of HS doesn't use any script like "speak.sh" that the Linux version does, so I have no way of triggering the python script when using hs.speak(). Every time I use hs.speak(), it goes straight to the speaker.exe app directly. I need a process similar to speak.sh so I can hook in and make the call to the python script and then play the received audio file after.

                  Comment


                    #24
                    Giving this a try this evening, HS3 build 478 on Raspberry Pi. Starting with PollyC.py3. My initial speak.sh
                    Code:
                    #!/bin/sh
                    # speak.sh
                    
                    exec > speak.log 2>&1
                    
                    mydir="$(dirname $0)"
                    cachedir="$mydir/PollyCache"
                    voice=Joanna
                    keyid="KEYID"
                    accesskey="ACCESSKEY"
                    region="us-west-1"
                    outfile="$mydir/pollyc.mp3"
                    
                    $mydir/PollyC.py3 --ofile "$outfile" --text "$1" --cache "$cachedir" --voiceid "$voice" --keyid "$keyid" --accesskey "$accesskey" --region "$region"

                    run 1:
                    Code:
                    File "/opt/HomeSeer/./PollyC.py3", line 87
                        print "mandatory option is missing\n"
                                                            ^
                    SyntaxError: Missing parentheses in call to 'print'
                    Added parentheses...
                    run 2:
                    Code:
                    Traceback (most recent call last):
                      File "/opt/HomeSeer/./PollyC.py3", line 54, in <module>
                        import boto3
                    ImportError: No module named 'boto3'
                    Get same message using PollyC.py.

                    boto3 is an AWS entity?

                    still on PollyC.py3, temp. comment out line 54...
                    run 3:
                    Code:
                    Traceback (most recent call last):
                      File "/opt/HomeSeer/./PollyC.py3", line 170, in <module>
                        main(sys.argv[1:])
                      File "/opt/HomeSeer/./PollyC.py3", line 86, in main
                        if not opts.__dict__[m]:
                    KeyError: 'keyid'
                    No idea about this. Jumping to PollyC.py, again with import boto3 commented out,
                    run 4:
                    Code:
                    Usage: PollyC.py [options]
                    
                    PollyC.py: error: no such option: --voiceid
                    Appears long options not working. Got same thing for keyid when I removed voiceid.
                    EDIT: not an issue - these options different from PollyC.py3 to PollyC.py

                    changed to use short options, PollyC.py still...
                    run 5:
                    Code:
                    Traceback (most recent call last):
                      File "/opt/HomeSeer/./PollyC.py", line 170, in <module>
                        main(sys.argv[1:])
                      File "/opt/HomeSeer/./PollyC.py", line 147, in main
                        polly = boto3.client('polly', region_name=a_region, aws_access_key_id=a_aws_
                    access_key_id, aws_secret_access_key=a_aws_secret_access_key)
                    NameError: global name 'boto3' is not defined
                    So need the boto3 import to go further...

                    Comment


                      #25
                      Installed python-pip, and boto3 - PollyC.py working! But PollyC.py3 still can't find boto3.

                      BTW, I'm building an installer for this, will post once working.

                      Edit: Voice selection (command line) doesn't seem to be working... always getting same voice.

                      And another edit! Voice selection does work; however the same phrase with a different voice invokes the cache, so isn't generated.

                      Also installed python3-pip and boto3, now PollyC.py3 is stuck at the "if not opts.__dict__[m]: ... KeyError: 'keyid' " problem.
                      Last edited by zwolfpack; September 24, 2018, 02:40 AM.

                      Comment


                        #26
                        Got voice out from Sonos! (uses speak_to_file.sh). Sounds as good as the IVONA voices I have on my production Windows system.

                        Sonos expects .wav file which Polly doesn't provide, so used mpg123 to convert. Modified speak_to_file.sh checks if the provided output filename ends with .wav or .WAV and does the conversion if so.

                        I wouldn't know Python if it bit me (see what I did there? ), but was able to add the voice into the hash calculation so that a change of voice is properly picked up.

                        Also found the issue with PollyC.py3 -- mixup of keyid/key_id and accesskey/access_key in the code. So that's working now. I will post my changes and installer after some more testing.

                        Comment


                          #27
                          is there any dif between using pollyc.py vs polly.py?

                          I mean in therm a functionality and speed?
                          Last edited by ; September 24, 2018, 03:00 PM.

                          Comment


                            #28
                            Originally posted by MattLau View Post
                            is there any dif between using pollyc.py vs polly.py?

                            I mean in therm a functionality and speed?
                            I am not aware of a "polly.py". The archive in post #1 contains PollyC.py (python2) and PollyC.py3 (python3).

                            My limited research indicates that the older 'jessie' Raspbian OS build only came with python2. Current 'stretch' build has both python2 and python3. No differences in functionality and any performance differences would be noise-level at best.

                            The installer I've put together checks for presence of python3 and uses that if available. It pulls in all packages required, specifically mpg123, python-pip, python3-pip and boto3 (from AWS). (I may need to tweak it for running on jessie, since I'm guessing that python3-pip may not be available there and might throw an error).

                            Comment


                              #29
                              Originally posted by zwolfpack View Post

                              I am not aware of a "polly.py". The archive in post #1 contains PollyC.py (python2) and PollyC.py3 (python3).

                              My limited research indicates that the older 'jessie' Raspbian OS build only came with python2. Current 'stretch' build has both python2 and python3. No differences in functionality and any performance differences would be noise-level at best.

                              The installer I've put together checks for presence of python3 and uses that if available. It pulls in all packages required, specifically mpg123, python-pip, python3-pip and boto3 (from AWS). (I may need to tweak it for running on jessie, since I'm guessing that python3-pip may not be available there and might throw an error).
                              Sorry for the typo. thanks you for the response

                              Comment


                                #30
                                Originally posted by MattLau View Post
                                is there any dif between using pollyc.py vs polly.py?

                                I mean in therm a functionality and speed?
                                Poly was the original program written by DeLicious. I took his code and added all of the caching routines and released it as PollyC. There are two versions of PollyC one for Python 2 and one for Python 3. The differences are in the formatting of some statements such as print. There are still some more things I'd like to add but I've been busy with other things.

                                One of the change would allow selecting the voice on a per call basic. What would be better is if HS3 allow parameter passing for TTS as it would make this easier but to get around that you'd have to add it in the text string.
                                HomeSeer Version: HS3 Standard Edition 3.0.0.548
                                Linux version: Linux auto 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
                                Number of Devices: 484 | Number of Events: 776

                                Enabled Plug-Ins: 3.0.0.13: AirplaySpeak | 2.0.61.0: BLBackup
                                3.0.0.70: EasyTrigger | 1.3.7006.42100: LiftMaster MyQ
                                4.2.3.0: mcsMQTT | 3.0.0.53: PHLocation2 | 0.0.0.47: Pushover 3P
                                3.0.0.16: RaspberryIO | 3.0.1.262: Z-Wave

                                Z-Net version: 1.0.23 for Inclusion Nodes
                                SmartStick+: 6.04 (ZDK 6.81.3) on Server

                                Comment

                                Working...
                                X