SmartThings Community

Better an Reloaded Fix for TTS (TextToSpeech)

tts
sonos
(Ule) #43

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”]
}
}

(Micheal ) #44

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.

(Morgan) #45

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?

(Patrick Musselman) #46

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.

(Ule) #47

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

Door left open (with Photo Burst, Hello Home, & Speech), Version 1.3.5
(Brian S. Lowrance) #48

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"]
    }
}
(Brian S. Lowrance) #49

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

(Rob) #50

@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

(Dean Smith) #51

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?

(Ule) #52

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

Thanks

(Dean Smith) #53

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

Thanks
Dean

(Ule) #54

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

(Dean Smith) #55

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:

(Dean Smith) #56

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?

(Ule) #57

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

(Dean Smith) #58

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.

(Ule) #59

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)
}
}

(Dean Smith) #60

@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?

(Ule) #61

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

(Matt Richling) #62

Having issues with the TTS function. I can play Internet radio and dogs barking. When I go to do any of the TTS or Sonos Weather - It isnt playing the file. It lists the file which I can play on my computer.

From what I read, the ST’s TTS is back up and running? Do we still need to use an external one? Could that be causing it? if I have it enabled?

Also - note the second log .

Thoughts?

b6b79cca-7593-4ace-b436-eac0aa2b641f 12:35:16 PM: trace Skipping event generation for sound file http://www.translate.google.com/translate_tts?tl=en&client=t&q=The%20current%20temperature%20is%202%20degrees.%20Today%27s%20forecast%20is%20Cloudy%20skies.%20High%203%20degrees.%20Win&sf=//s3.amazonaws.com/smartapp-&ts=1450287296774%20 b6b79cca-7593-4ace-b436-eac0aa2b641f 12:34:59 PM: error org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 2766; The reference to entity "client" must end with the ';' delimiter. @ line 197 b92b4906-7483-40dd-95c7-bba51cfc3005 12:34:56 PM: trace uri: http://www.translate.google.com/translate_tts?tl=en&client=t&q=The%20current%20temperature%20is%202%20degrees.%20Today%27s%20forecast%20is%20Cloudy%20skies.%20High%203%20degrees.%20Win&sf=//s3.amazonaws.com/smartapp- b92b4906-7483-40dd-95c7-bba51cfc3005 12:34:56 PM: trace cleanUri(x-rincon-mp3radio://www.translate.google.com/translate_tts?tl=en&client=t&q=The%20current%20temperature%20is%202%20degrees.%20Today%27s%20forecast%20is%20Cloudy%20skies.%20High%203%20degrees.%20Win&sf=//s3.amazonaws.com/smartapp-,WD TV) b92b4906-7483-40dd-95c7-bba51cfc3005 12:34:56 PM: trace state.sound [uri:x-rincon-mp3radio://www.translate.google.com/translate_tts?tl=en&client=t&q=The%20current%20temperature%20is%202%20degrees.%20Today%27s%20forecast%20is%20Cloudy%20skies.%20High%203%20degrees.%20Win&sf=//s3.amazonaws.com/smartapp-, duration:13] b92b4906-7483-40dd-95c7-bba51cfc3005 12:34:56 PM: error java.lang.reflect.UndeclaredThrowableException b92b4906-7483-40dd-95c7-bba51cfc3005 12:34:56 PM: trace normalize