SmartThings Text-To-Speech for Sonos (playText) not working?

It seems that anything that has been “said” by anyone before as its MP3 cached on SmartThings side and still works, but any new phrases do not.

Is this custom code or one of our apps?

It’s custom code based on one of your apps. I’m sending this to the app:
{“value”:“Hello MyName”,“command”:“playTextAndResume”}

The result I get back in the live logs:
10:03:44 AM: error org.springframework.transaction.HeuristicCompletionException: Heuristic completion: outcome state is rolled back; nested exception is org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only @ line 204
10:03:43 AM: debug Sending playTextAndResume to Sonos Play3

If I send “Good Morning” OR any other common phrases, they’ll work fine - I’m guessing because SmartThings already has them cached in their S3 bucket.

Can you share the code? Either privately or here? I’d love to take a look. I think you might be missing some key pieces.

Thanks Tim - just sent you a PM.

Looking into this. Seems to be a wider issue. I’ll update when I have something :smile:

Thanks, Tim! I’ve been seeing playText() oddities as well that I didn’t think were there in the past.

Tim,

This is the same issue you and I discussed this morning…

I fixed it myself by using tts-api.com to generate an MP3 link then just sending playTrack…

I have never heard of that, but that is kinda neat! I assume you use it like this "playTrack(“http://tts-api.com/tts.mp3?q=text to speak”)? I believe there is a parameter for duration that is required as well…do you account for that? Can you share a code snipit?

No duration required… I’m literally just doing exactly what you describe except I’m adding ‘&return_url=1’ to the tts-api URL. Make sure to url encode what you want to say to avoid bugs with special characters.

I guess that is the part that confuses me…are you ‘prestaging’ the url into a variable, essentially replacing the textToSpeech API? So instead of:

def text = "this is a test"
def url = textToSpeech(text, true)
playTrack (url.uri)

You would have something like:

def text = "this is a test"
def url = something to convert the tts-api to an uri
playTrack (url.uri)

or are you simple doing the following:

def url = "http://tts-api.com/tts.mp3?q=this+is+a+test&return_url=1"
playTrack (url)

If it is the last one, not sure why you would care to add the &return_url=1 to the end of it as the URL should just place the mp3 (or should…I am not in front of my Sonos to test this).

I’m using this as part of a custom API call, not directly in a smartapp, so it may not matter.

Ah…cool…thanks! I appreciate it…

Not to hijack this thread, but is there an easy way within groovy to send a URL like the TTS-API and capture the resulting text that would normally appear in the browser? I guess like a curl command? I looked at the httppost and httpget commands, but it almost appears they are expecting some sort of JSON to be returned. Anyway it is possible to catch the resulting url link with SmartThings?

@slagle - Is this something that’s going to be fixed soon, or is it a lower priority? I’ve got a project that hinges on playText working, so I don’t want to dump more time into it if there’s no fix in the pipeline.

Any idea when this will be fixed

1 Like

I’ve been having issues with sonos as well… As per support some combinations of words dont work… True ! When i use “leak detected” it fails to save page for a water sensor sonos voice notification. But when i write “water detected”, it saves…

Like I mentioned, it seems that phrases they have previously cached work, but new phrases do not.

@slagle

Any news? Is anyone working on this?