Author Topic: Amazon Polly TTS alternative approach  (Read 1371 times)

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: Amazon Polly TTS alternative approach
« Reply #15 on: July 30, 2017, 01:25:40 pm »
It's ok @BOFH, I wouldn't do that. they are just dummy credentials :)

You'll notice the word 'Not Mine' hidden in the access key ID

However, if it still works - BONUS !!
« Last Edit: July 30, 2017, 01:54:41 pm by parkerc »

Offline BOFH

  • Sr. Hero Member
  • ******
  • Posts: 2410
  • Karma: +112/-139
Re: Amazon Polly TTS alternative approach
« Reply #16 on: July 30, 2017, 03:11:16 pm »
Nice one! I missed that...
Vera3 UI5 UI7 Edge Plus
Trane TZEMT400AB32 | Schlage BE369 FE599 | GE 45601 45602 45603 45604 45606 45609 45631 | Intermatic HA01C HA03C HA05C HA07C CA600 CA3000 | Aeon DSC06106 | Telguard GDC1 | Foscam FI8910W FI8905W FI9821W | D-Link 930L | Wanscam JW0011 | ZModo ZPIBH13W

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: Amazon Polly TTS alternative approach
« Reply #17 on: July 31, 2017, 06:10:15 am »
Hi @kapstaad

Using your code as a global function, I can't seem to get it to play in just one zone (my office) ? Can you ?  The code I used is as follows.

Code: [Select]
Polly("This is a test of Polly, the Amazon speech engine.", 60, Office")
I thought this should play in my office at 60% volume, but it's not. Everything I've tried seems to default the http.request URL to "/sayall/" rather than /office/say/ ?
« Last Edit: July 31, 2017, 03:31:45 pm by parkerc »

Offline kapstaad

  • Sr. Newbie
  • *
  • Posts: 44
  • Karma: +1/-0
Re: Amazon Polly TTS alternative approach
« Reply #18 on: August 01, 2017, 09:19:50 pm »
Hi @kapstaad

Using your code as a global function, I can't seem to get it to play in just one zone (my office) ? Can you ?  The code I used is as follows.

Code: [Select]
Polly("This is a test of Polly, the Amazon speech engine.", 60, Office")
I thought this should play in my office at 60% volume, but it's not. Everything I've tried seems to default the http.request URL to "/sayall/" rather than /office/say/ ?

Two possibilities; first, do you definitely have a Sonos unit called "Office"?

Second, it might be as simple as a typo... you're missing a quote mark before the word "Office" in the code snippet:

Code: [Select]
Polly("This is a test of Polly, the Amazon speech engine.", 60, "Office")                                                                                           ^-------------------this quote mark is missing in your example.

Good luck!


Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: Amazon Polly TTS alternative approach
« Reply #19 on: August 02, 2017, 05:03:36 am »
Thanks @kapstaad

That was it, the name of the zone needed to be in quotes - more examples below :)

Code: [Select]
Polly("This is a test of Polly, the Amazon speech engine.", 60, "office")

---

Polly("This is a test of Polly, the Amazon speech engine.", 60, "living room")

---

Polly("This is a test of Polly, the Amazon speech engine.", 60, "kitchen")

What I have noticed as I walked through each of the above - is that the first request made to a zone, Polly does not completely say the text submitted.  But If I try it again it does. 

Have you noticed this as you switch between using specific zones one at a time ? ?

« Last Edit: August 02, 2017, 11:19:11 am by parkerc »

Offline Thanster

  • Newbie
  • *
  • Posts: 8
  • Karma: +1/-0
Re: Amazon Polly TTS alternative approach
« Reply #20 on: August 10, 2017, 03:20:39 pm »
I'd like to say a big "Thank you!" for this info; it took me a couple of hours of not particularly hard work; I setup an AWS account, configured it for credentialed access to Polly, added nodejs and npm 8.x to my Raspbian Jessie Pi, configured the api node, and have since converted all of my spoken system messages to use Polly's "Joanna" voice. Works great!  Thank you!  :D

You're welcome and thank you for the kind words. Glad it worked out!

I did something similar. using polly, but instead of cloud-rendering on the fly, i wrote a cache system, so after is speaks a phrase, it's cached and no re-rendering is needed.
it's not like saying "the garage door is open" is going to change. so why render every time. cache and then play the cached file.
I do really like the whole aws and polly system. its well developed and has a ton of options.

The Node.js Polly module includes a local cache by default  It only connects to Polly once for each unique announcement.  I just checked my AWS usage metrics, and I can confirm it works.  All of my announcements have now been cached, and it hasn't connected to Polly in over a month even though I use it every day.

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: Amazon Polly TTS alternative approach
« Reply #21 on: August 27, 2017, 04:33:03 pm »
Hi

Ive just had to create a new Docker for the sonos-http api and I have updated the settings.json with my amazon details and it looks to be sending request through ok, except Sonos reports an error ? See the following.

Quote
Unable to play 'google-60bc2345a7878b38383deoeowo3-Joanna.mp3' - the song is not encoded correctly

Is anyone else seeing this ?

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: Amazon Polly TTS alternative approach
« Reply #22 on: August 29, 2017, 02:15:12 pm »
Ok. Fixed the inclusion of the word Google at the start should have been a tel tale sign, as that is the default TTS engine - which means it was not reading my settings.json file with my amazon credentials..

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: Amazon Polly TTS alternative approach
« Reply #23 on: September 08, 2017, 12:23:36 pm »
Hi - I've been trying to use the Polly function to occasionally use a different voice, and while i can get that to work with one zone, (code below)

Code: [Select]
Polly ('While you are waiting. Here is a joke...  What happens if a frog parks illegally. It gets toad..', 70, "office", "Geraint" )
I can't make it play that voice across all zones..

I thought replacing "office" with "sayall" might work but sadly no, if anyone has this working please could they share.