Better an Reloaded Fix for TTS (TextToSpeech)

I am going to play with it this weekend…my main goal is to get the Sonos stuff working for the apps that I have published…but want to make it as compatible as I can.

Thanks!

Hu, Could some one help me to test this functions?

first test:

private textToSpeechT(message){
if (message) {
[uri: “http://www.translate.google.com/translate_tts?tl=en&client=t&q=” + URLEncoder.encode(message, “UTF-8”).replaceAll(/+/,’%20’) +"&file=ule.mp3", duration: “${5 + Math.max(Math.round(message.length()/12),2)}”]
}else{
[uri: “http://www.translate.google.com/translate_tts?tl=en&client=t&q=” + URLEncoder.encode(“You selected the Text to Speach Function but did not enter a Message”, “UTF-8”).replaceAll(/+/,’%20’) +"&sf=//s3.amazonaws.com/smartapp-&", duration: “10”]
}
}

Second test:

private textToSpeechT(message){
if (message) {
[uri: “http://www.translate.google.com/translate_tts?tl=en&client=t&q=” + URLEncoder.encode(message, “UTF-8”).replaceAll(/+/,’%20’) +"&sf=//s3.amazonaws.com/smartapp-&file=ule.mp3", duration: “${5 + Math.max(Math.round(message.length()/12),2)}”]
}else{
[uri: “http://www.translate.google.com/translate_tts?tl=en&client=t&q=” + URLEncoder.encode(“You selected the Text to Speach Function but did not enter a Message”, “UTF-8”).replaceAll(/+/,’%20’) +"&sf=//s3.amazonaws.com/smartapp-&", duration: “10”]
}
}

Both of these give the following error:

java.util.regex.PatternSyntaxException: Dangling meta character ‘+’ near index 0

In addition, the "x-rincon-mp3radio protocol " doesn’t work with my sonos but throws no errors.

This isn’t workin for me at all. I just want to be able to change my Sonos text, and it isn’t working at all.

Is ST working on this soon?

@Tyler anyone?

Is this working now? It must be. I had installed the BigTalker app several weeks ago to test it out and it did not work. Today I rebooted my hub and then came home and opened one of the test sensor a TTS over Sonos played. Hope it keep working.

Hi @pmusselman, Smartthings has fixed the TTS Function, if you are using some smartapp with TTS fix you must to revert to original SmartApp

In @geko’s VLCThing 1.2.2 Device Type, I was getting the following error when attempting TTS with BigTalker 1.1.2: java.lang.reflect.UndeclaredThrowableException @ line 584

Line 584 of VLCThing calls: def sound = textToSpeech(text, true)
So there is definitely still a problem with calling textToSpeech(text, true) against the current platform.

I replaced the “myTextToSpeech()” function in my VLCThing Device Type with your code and it is now working. Thanks for this info!

private def myTextToSpeech(message) {
    //Disabled due to SmartThings TTS platform issue.
        //def sound = textToSpeech(text, true)
        //sound.uri = sound.uri.replace('https:', 'http:')
        //return sound
    //Below is a fix until SmartThings TTS platform is fixed
    if (message) {
        [uri: "http://www.translate.google.com/translate_tts?tl=en&client=t&q=" + URLEncoder.encode(message, "UTF-8").replaceAll(/\+/,'%20') +"&sf=//s3.amazonaws.com/smartapp-&", duration: "${5 + Math.max(Math.round(message.length()/12),2)}"]
    }else{
    	[uri: "http://www.translate.google.com/translate_tts?tl=en&client=t&q=" + URLEncoder.encode("You selected the Text to Speach Function but did not enter a Message", "UTF-8").replaceAll(/\+/,'%20') +"&sf=//s3.amazonaws.com/smartapp-&", duration: "10"]
    }
}

Well, that worked for a little while (a few hours) and then quit. So I did some digging and found that I’m now being blocked by Google for unsual traffic.

Our systems have detected unusual traffic from your computer network. Please try your request again later. Why did this happen?

This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the Terms of Service. The block will expire shortly after those requests stop.

This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests. If you share your network connection, ask your administrator for help — a different computer using the same IP address may be responsible. Learn more

Sometimes you may see this page if you are using advanced terms that robots are known to use, or sending requests very quickly.

I’m using the original unmodified VLCThing 1.2.2 Device Type again (@geko) with the standard SmartThings textToSpeech(txt,true) call and it’s working again… for now… #ConsistentlyInconsistentPlatform

@ule,

I just attempted today to generate a new TTS message for Sonos device, and its still not working. Its only working with pre-generated TTS messages still…

Can anybody else confirm if their TTS is working correctly for Sonos?

-Rob

I just wanted to say - I updated the Smartapp & Device type but it appears to have caused a few issues.

I now cant delete the 2 devices that were connected with Media renderer connect. I get the follwoing message:

No signature of method: script14459763896711909525532.getChildDevices() is applicable for argument types: () values: []

Anyone able to help here?

Hi @deano12, Could you update again the MediaRenderer connect and try to show me the log

Thanks

Ok - Just so I’ve got this right - MediaRenderer.Connect is a device type or a smartapp?

Thanks
Dean

Hi @deano12, The media Renderer connect its a SmartApp who search for devices , The device type “DLNA player” id added for each device found it by the connect

Ok think I fixed it. Managed to get the devices deleted and also the device type and smart app… Re-installed everything from updated codes and all seems to be loading ok, where as before, it crashed the app if I opened my TV’s device. So will test output tomorrow when I get home for lunch.

Many thanks :smile:

Got another issue - I’m getting for custom message “You selected the Text-To-Speech function but did not enter a message” when I select custom message. Its rather annoying tbh as the messages are in the correct field… Anyone had this before or got any clues?

Hi @deano12, Where are you using the function , some of my smart apps?

Hi @ule Yes, it was from the code you’ve put latest in this thread… I can see the errors in code, but it doesnt look like its processing the translation.

Hi @deano12, I´m assuming you are adding this function to your smartapp, please verify you are calling the function correctly, the safeTextToSpeech is a example how to catch the error, but you can see that the result is send it to a state variable

it´s possible the problem is that you want to us it directly, in this way the function will return the result from the ttsfunction

private safeTextToSpeech(message) {
message = message?:"You selected the Text to Speach Function but did not enter a Message"
log.trace "safeTextToSpeech(${message})"
try {
textToSpeech(message)
}
catch (Throwable t) {
log.error t
textToSpeechT(message)
}
}

@ule - Thanks - This looks like its the answer! However, how do I get it so that it plays the text that I enter into the field on the smartapp from the main SmartThings app?

HI @deano12, I have update the Fix with a great service, try to check the code in https://github.com/SmartThingsUle/DLNA-PLAYER/blob/master/Sonos_Weather_Forecast_External_TTS.groovy