BTK above us right…the reason that you got your weather report and the "this is a test’ started working is that those text phrases were already cached at the service that does the textToSpeech. If you would have changed the “this is a test” to “this is a test Pat” you would have gotten the same throwable exception. I tried modifying the Alarm Clock app that I wrote with the ‘toSting()’ and got the same log issue (throwable exception).
Pat, if you can test this on your end with the code you used last night please confirm this…just change the text to random words and I am willing to bet the issue remains.
I am not sure there is a work around…the coding session used a phrase that might have already been ‘cached’ by the service that ST uses to ‘translate’ the text to speech. So, no translation actually took place so they didn’t really fix the issue.
I had high hopes when I looked into it, but then I saw that the phrase used for testing was “this is a test” – which is more than likely cached already.
Looking at the same “Sonos Notify with Sound” code, you can mock around with the message until you’re blue in the face but it doesn’t seem to work with a custom phrase, even if you throw away the message and create a new one and explicitly define it as text.
The idea is that something like this would solve the problem:
def msg = "some random text that hasn't been spoken before"
state.sound = textToSpeech(msg.toString())
I’ve tried that and couldn’t get it to work personally, but anybody else that wants to give it a shot and let me know if / how they got it to work, please do.
Same with me…I think the .toString was a red herring…
I just got my Alexa set up and I think I am in love with her:) I have a ‘relationship’ with Ivee previously that I literally had to scream at her just to set an alarm. Alexa is a LOT better and I may focus on that instead of the Sonos issue, which seems to be a bit more difficult to solve.
Confirmed. I just used @pstuart’s code and it works as expected since “this is a test” is already cached. If I change line 63 to “This is a test. Moo.” I get the UndeclaredThrowable.
Yeah, the caching mechanism clearly is responsible for this working sometimes and not others.
No idea what is broken, but both methods sonos.playText(string) and textToSpeech(string) both return an error when called.
My guess is it is something simple like whatever api they are using to get the tts, and it is blocking the requests. If it is google, they did introduce a captcha recently to reduce abuse…
I’m not sure I understand this caching thing… do they have a cached copy of every phrase out there and serve it out to everyone? I can see this working for common phrases, but what about weather forecasts? Is it composing the sound file to play word by word, and when the “new” words are missing in the cache then it throws the exception?
Also, with the “Morgan Freeman” change in the other thread, it looks like you can create your own phrases, on your own bucket, and have the smartapp use the phrases from there rather than rely on the ST version of the phrases. Or am I misunderstanding how that works?
Sort of. The Morgan Freeman one has pre-generated MP3 files for each phrase. With the ST TTS functions, you can have it speak arbitrary phrases. With the MF solution, you need to have those phrases pre-determined and then select one to play.
So if your program is only ever going to say one of X things, sure. Pre-record all your possibilities and hard-code the URLs into your SmartApp. If your program needs to be able to say programmatically-generated things, that’s where the TTS functions become very useful.
Last response I got from support was they know about it, but it isn’t the highest priority at the moment to put resources on it to fix it.
Guess you just have to open a ticket and see if we can change their minds. Might be something else going on that might be pulling resources away from fixing issues that have been around for a long time…
This appears to be happening again, or maybe it was always happening.
For some reason my Yamaha loves DLNA playing mp3s off s3 but refuses to do any of the TTS apis I plugged into it. Which means no weather for me yet… Ideas?