Announcement

Collapse
No announcement yet.

Annonuncements using AWS Polly and Sonos

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

  • MattL0
    replied
    ok got it i think https://forums.homeseer.com/forum/ho...g-amazon-polly

    Leave a comment:


  • MattL0
    replied
    can't access it Timon & Pumbaa.

    Do you think It'll works with Squeezebox since it needs and mp3 files for tts?

    Leave a comment:


  • Timon
    replied
    BTW the thread I wrote for PollyC is located below

    https://forums.homeseer.com/forum/ho...g-amazon-polly
    Last edited by Timon; September 5th, 2018, 10:57 AM.

    Leave a comment:


  • bsobel
    replied
    So I came into this thread about 15 months later and hit the exact same problem. I found the quickest solution was to modify my speak_to_file.sh to:

    #!/bin/sh
    # For Python2 change ./PollyC.py3 to ./PollyC.py
    ./PollyC.py -o "$1.tmp" -t "$2" -c "./pollycache/" -k "1F5Q1JW3JNZEC9HMX5G2" -a "l//b6T4gzjCk3QxJa+JWBIRmpXb2vw89adURFOEu"
    mpg123 -w "$1" "$1.tmp"
    rm "$1.tmp"

    So now the PollyC script writes out the translated or cached file to $1.tmp That is converted to a wave file (the file name provided by HomeSeer) then I delete the tmp file. Extra processing (may cache that at some point) but no noticeable delay is added in my tests for far.

    Leave a comment:


  • sigbjorn
    replied
    Originally posted by dcorsus View Post
    I looked at the code and we have a bit of a challenge. My PI calls HS which in terms calls some TTS engine. The HS call has no parameter to tell the PI that the returned file is not .wav, so I have no way to know what format I received. Clearly Sonos is not forgiving enough if I present it with a .wav extension and/or meta data indicating a wave format file. SO, why don't you try and have the AWS-service return an audio/pcm format, see if Sonos doesn't choke on it.

    Dirk
    I have tried the PCM format, and all though it's a Wav format, it's not the correct encoding. I'll see if I can run it through a script so it will get the right encoding. Only thing I'm a bit worried about, is the delay of this process.

    Sent from my E5823 using Tapatalk

    Leave a comment:


  • dcorsus
    replied
    Originally posted by sigbjorn View Post
    Thank you Dirk!
    I have already done some testing, and the AWS-service can in fact return files in wav-format. But the format isn't compatible with either Windows or Linux. The content-type is audio/pcm and not audio/wav. I'll do some more digging and try to find a solution.
    But, it works in regular speaker clients. ;-)

    Sigbjorn
    I looked at the code and we have a bit of a challenge. My PI calls HS which in terms calls some TTS engine. The HS call has no parameter to tell the PI that the returned file is not .wav, so I have no way to know what format I received. Clearly Sonos is not forgiving enough if I present it with a .wav extension and/or meta data indicating a wave format file. SO, why don't you try and have the AWS-service return an audio/pcm format, see if Sonos doesn't choke on it.

    Dirk

    Leave a comment:


  • dcorsus
    replied
    Originally posted by dcorsus View Post
    Will have to look at the code. I'm so used to have this run under Windows whereas the output was a wav file and I'm pretty sure I might be adding the file extension myself.

    Having that said and you being dependent on me finding time to look at this, I would be surprised if there isn't a parameter somewhere in all the scripts you run, to have a .wav file produced instead of an .mp3. So google a little on the parameters you are using left and right, I'd be surprised if with a simple change all of this can't be made to work with existing PI functions.

    Dirk
    This would be the line to change:

    response = polly.synthesize_speech(OutputFormat='mp3', Text=text, VoiceId='Joanna')

    However a quick search results that the only Outputformats supported are:
    Valid Values: mp3 | ogg_vorbis | pcm

    I guess I'll have to look at my code .....

    Dirk

    Leave a comment:


  • sigbjorn
    replied
    Thank you Dirk!
    I have already done some testing, and the AWS-service can in fact return files in wav-format. But the format isn't compatible with either Windows or Linux. The content-type is audio/pcm and not audio/wav. I'll do some more digging and try to find a solution.
    But, it works in regular speaker clients. ;-)

    Sigbjorn

    Leave a comment:


  • dcorsus
    replied
    Originally posted by sigbjorn View Post
    OK!
    A step further, thanks to your tips on looking at the Sonos app. It states "SonosController Announcement" and an error message saying

    "Unable to play HomeSeer Announcement. The song is not encoded correctly."

    As I said in the first post, it plays well on a speaker client, so what can be wrong with the encoding?

    I accessed http://10.0.0.100/Sonos/Announcements/Ann_TTS_ALL_0.wav in my browser, and everything sounds good.

    Update:
    I looked at the Python script, generating the file from Amazon, and it is in the format of mp3. But the file saved i Ann_TTS_ALL_0.wav. I renamed the file-extension to mp3, and now the file is played over my Sonos speakers.
    Final question is then: How can I always assure the announcement file is saved as .mp3 and not .wav?

    Sigbjorn
    Will have to look at the code. I'm so used to have this run under Windows whereas the output was a wav file and I'm pretty sure I might be adding the file extension myself.

    Having that said and you being dependent on me finding time to look at this, I would be surprised if there isn't a parameter somewhere in all the scripts you run, to have a .wav file produced instead of an .mp3. So google a little on the parameters you are using left and right, I'd be surprised if with a simple change all of this can't be made to work with existing PI functions.

    Dirk

    Leave a comment:


  • sigbjorn
    replied
    OK!
    A step further, thanks to your tips on looking at the Sonos app. It states "SonosController Announcement" and an error message saying

    "Unable to play HomeSeer Announcement. The song is not encoded correctly."

    As I said in the first post, it plays well on a speaker client, so what can be wrong with the encoding?

    I accessed http://10.0.0.100/Sonos/Announcements/Ann_TTS_ALL_0.wav in my browser, and everything sounds good.

    Update:
    I looked at the Python script, generating the file from Amazon, and it is in the format of mp3. But the file saved i Ann_TTS_ALL_0.wav. I renamed the file-extension to mp3, and now the file is played over my Sonos speakers.
    Final question is then: How can I always assure the announcement file is saved as .mp3 and not .wav?

    Sigbjorn
    Last edited by sigbjorn; March 15th, 2017, 11:59 AM.

    Leave a comment:


  • dcorsus
    replied
    Originally posted by sigbjorn View Post
    Thank you for your quick response!!

    I'm not running any scripts, only a test event.

    [ATTACH]60084[/ATTACH]

    This is my speak_to_file.sh:

    Code:
    #!/bin/sh
    #flite -voice slt -o "$1" -t "$2"
    ./polly.py -o "$1" -t "$2"
    and the polly.py is the same as in the post I mentioned.

    I did a second attempt, running &hs.speak("hello") from the command window, and I got output on the Android client, but not on Sonos. I activated the debug flag before the test and here's my log file:

    [ATTACH]60082[/ATTACH]

    Regards
    Sigbjorn
    The hs.speak is not supposed to be picked up by the Sonos PI, so it is the wrong test.

    You need to activate the event and trace that with the Sonos PI debug flag on. Even before you go there, have you looked at the Sonos controller APP what it shows when you activate the event?
    Could you also post your linkgroup table?
    I'm miles away from being a Linux expert but what is the content of the speak_to_file.sh content when it works with the sonos PI?

    Dirk

    Leave a comment:


  • sigbjorn
    replied
    Thank you for your quick response!!

    I'm not running any scripts, only a test event.

    Click image for larger version

Name:	event.jpg
Views:	1
Size:	21.4 KB
ID:	1190220

    This is my speak_to_file.sh:

    Code:
    #!/bin/sh
    #flite -voice slt -o "$1" -t "$2"
    ./polly.py -o "$1" -t "$2"
    and the polly.py is the same as in the post I mentioned.

    I did a second attempt, running &hs.speak("hello") from the command window, and I got output on the Android client, but not on Sonos. I activated the debug flag before the test and here's my log file:

    Click image for larger version

Name:	log.jpg
Views:	1
Size:	47.2 KB
ID:	1190219

    Regards
    Sigbjorn

    Leave a comment:


  • dcorsus
    replied
    Originally posted by sigbjorn View Post
    Hi!
    I have read this thread https://forums.homeseer.com/showthread.php?t=186070 and implemented the script the way it was suggested.
    When I now try to speak through a speaker client (Android), everything is well. I get the expected announcement with the exceptional AWS voices from Amazon.

    If I try to route the announcement to my Sonos link group, $SONOS$TTS_ALL$, nothing happens. In the log I can see the error message: Error in DoCheckAnnouncementQueue. 100 seconds expired since the announcement started and no end was received.

    If I use the default setup in speak_to_file.sh, without running this through the AWS script, I get the announcement over my Sonos speakers.

    Any ideas, what could be wrong?
    You mind post the screen shot of the speak action and post your working and non-working script files.

    Dirk

    Leave a comment:


  • sigbjorn
    started a topic Annonuncements using AWS Polly and Sonos

    Annonuncements using AWS Polly and Sonos

    Hi!
    I have read this thread https://forums.homeseer.com/showthread.php?t=186070 and implemented the script the way it was suggested.
    When I now try to speak through a speaker client (Android), everything is well. I get the expected announcement with the exceptional AWS voices from Amazon.

    If I try to route the announcement to my Sonos link group, $SONOS$TTS_ALL$, nothing happens. In the log I can see the error message: Error in DoCheckAnnouncementQueue. 100 seconds expired since the announcement started and no end was received.

    If I use the default setup in speak_to_file.sh, without running this through the AWS script, I get the announcement over my Sonos speakers.

    Any ideas, what could be wrong?
Working...
X