TTS interface (text to speech)

tts
function
methods

#1

Application and Driver method

Map textToSpeech(String text, String voice = null)

Returns:
uri: local path to generated mp3
duration: mp3 duration in integer seconds

Returns null if an invalid voice is requested

Parameters:

Type Parameter Description
String text text string to be synthizized, may include inline SSML
String voice AWS poly voice id, defaults to current system setting, currently "Matthew"

Helper methods:

Map getTTSVoices()

Returns:
name: voiceId
gender: Male | Female
language: languageName

Examples:

//tts
def tts = textToSpeech("What's up guys?") //default voice
def tts = textToSpeech("What's up guys?","Salli") //Salli, Female, English (US)

//SSML
def text = "<amazon:effect name='whispered'>What's going on guys?</amazon:effect><break time='1s'/>guys?" 	

//sorted voice list suitable for enum input options
def getVoices(){
	def voices = getTTSVoices()
	voices.sort{ a, b ->
		a.language <=> b.language ?: a.gender <=> b.gender ?: a.gender <=> b.gender  
	}    
    def list = voices.collect{ ["${it.name}": "${it.language}:${it.gender}:${it.name}"] }
	return list
}

TTS Working great!
Tts voice selection
Set TTS Voice locally
[RELEASE] Follow Me
pinned #2

#3

Mike,

Are you going to update Capability Music Player and Audio Notification to allow for the voice entry? (If not, I will accommodate choice in a driver preference.)


#4

It will be a global setting on the hub fairly soon, but for now I would make it a driver preference if you wish to change it.


#5

Need advice. I like the TTS feature; however, I am having problems on one of my two speaker models.

Samsung R1 speakers have a custom "setURLPlayback" command. TTS works great.

Newer soundbars (different SW) uses standard UPNP AV Transport interface.
a. It works with Audio Notification coming from an external source. It sends the command and the expected response is received.
b. It doesn't work with internal text-to-speech. Command is sent, but no response is received from the Soundbar.

There is something in the format going to the player that I have wrong. I have loaded the TTS output string (stored on hubitat) into the smart app as an optional sound. Below are results (the 192 address is my local hub address.

Doesn't work: "http://192.168.1.112:8080/tts/348f444da85fd6d6b4a22e1088594b95.mp3"

Works: "http://s3.amazonaws.com/smartapp-media/sonos/dogs.mp3"

At the same time, I am able to have the voices.rss text-to- speech work with the soundbar (using UPNP). That string is:

" http://api.voicerss.org/?key=d79154704143efb9f4ffac44ffbbc1&f=48khz_16bit_stereo&hl=en-gb&src=This%20is%20a%20test"

Pretty sure it is something in MY Hubitat TTS output formatting. HELP!


#6

First guess is that it doesn't,like port 8080, but there isn't anything we can do about that atm.


#7

I am delinquent in saying THANK YOU for adding the SSML support into the TTS string! Now I can play my announcements on the Bose speakers and the text is not cut off at the beginning :smile:

We picked Brian for the voice, sounds like we have an English butler in the house :wink:

Now looking forward to the lock manager app!

Hard to believe that I waited YEARS for a home automation hub that would do everything I wanted, and now I am almost there. So glad to have stumbled upon Hubitat!


#8

Would you share just how you "stumbled upon Hubitat"?


#9

I have a Vera Plus hub (which BTW is currently off) and somebody mentioned Hubitat on the forum...I have made a few posts on the forum mentioning how great Hubitat is :wink: .

I started out with SmartThings and dumped them when they discontinued support for Windows Phone. I couldn't understand why they didn't have web-based configuration, who wants to do that on a phone??? And like most others, I didn't like the cloud-based system.

Vera Plus sounds great, but their ZigBee support is seriously lacking. I tried to create a plug-in that didn't work on the phones but worked OK on the web interface. You cannot create your own device drivers and they are more concerned with doing a security system and updating the user interface than supporting devices. They also have released a lot of buggy firmware. So I was looking for alternatives...thank goodness I found Hubitat!


#10

Is there a way to transfer the TTS file from Hubitat to my PC? (or can you send me one you create). I can then try to play in on my speaker independent of Hubitat and verify the problem is NOT the Hubitat environment.


#11

If you generate one on your end you should be able to down the file via a browser.


#13

Mike, I was able to extract the TTS mp3 file to my PC and using Windows Media Player play it on both my PC and cast it to the Samsung MS650 soundbar. Because I am anal, below is a single point summary:

Problem: Hubitat TTS implementation of TTS does not play on the Samsung HW-MS650 Soundbar using the AVTransport capability. Using the same driver, I am able to play mp3 files from other URIs.

HW-MS650 Soundbar. This and all "Sound +" soundbars from Samsung use the AVTransport capability to play audio at a specific URI. (This is different from the Samsung Radiant speakers and older soundbars that do not have the AVTransport capability.)

Testing to-date.

  1. Verified that the MS650 can play via driver from non-Hubitat URIs (my cloud drive and api.voices.rss)
  2. Tried using the different ports for the Hubitat URI as well as using no port at all.
  3. Verified the Hubitat URI plays using a browser (Firefox).
  4. Verified Soundbar can have audio cast from PC (Windows Media Play).
  5. Downloaded sound file from Hubitat. Loaded sound file into PC's media library and played on my PC.
  6. Successfully cast the sound file to the speaker using windows media player.
  7. Verified that when the soundbar receives the speaker command and sends AVTransport HEAD request to my PC (used Wireshark to verify).

Conclusions: Have eliminated all causes except the interaction between Hubitat and the soundbar. I also know the soundbar is successfully communicating the HEAD command and that is responded to properly.

Next. I can capture the PC-Speaker HEAD request and Response for the extracted TTS audio. But, I can not compare this to the Hubitat protocol implementation.

REQUEST. If I extract the HEAD request and response from a successful transfer to the Soundbar, will you have it looked at to see if the problem is Hubitat or the soundbar?


#14

Additional information on TTS and Samsung MS650 Soundbar issue.

I captured a Windows Media Player success in casting a Hubitat-created TTS file to the MS650. One thing I noticed was the HTTP Section in wireshark:

Hypertext Transfer Protocol
POST /upnp/control/AVTransport1 HTTP/1.1**\r\n**
Cache-Control: no-cache**\r\n**
Connection: Close\r\n
Pragma: no-cache\r\n
Content-Type: text/xml; charset="utf-8"\r\n
User-Agent: Microsoft-Windows/10.0 UPnP/1.0 Microsoft-DLNA DLNADOC/1.50\r\n
FriendlyName.DLNA.ORG: DGUTHEINZ\r\n
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"\r\n
Content-Length: 4639\r\n
Host: 192.168.0.109:9197\r\n
\r\n
[Full request URI: http://192.168.0.109:9197/upnp/control/AVTransport1]
[HTTP request 1/1]
[Response in frame: 510]
File Data: 4639 bytes

Of note is the "\r\n" after each line. When trying to get hubSoapAction to work, it did not originally work (since fixed). I believe the reason was that the Hubitat HTTP implementation used only "\r", Is this possibly the case here????

Dave


#15

It there a way to make a Windows or Mac computer on the network appear as a TTS capable device? I have an old Mac laptop sitting idle, and I would love for it to serve this purpose if it could. I'm not a developer, so I'd need either some guidance to making it happen with the built-in capabilities, or a pointer to the additional software I would need to make it work.

I came across this application that would work with the addition of TTS via casting that will eventually be available, but the price is a little high, vs just buying a Google Mini and then having those additional capabilities.


#16

I think you can run VLC on your computer, and then run the VLC Thing App on your hub. I haven't done it personally on Hubitat, but I had it working on ST a couple years ago.


#17

I can confirm this works in hubitat.


#18

The TTS uri that's generated and returned from our tts method is nothing special.
You can see what's being returned by taking a generated uri and dumping it into a postman get request.
I did notice that we aren't returning a content type header in the response, perhaps this is what the sami transport doesn't like?

In the end, the uri we generate needs to be formatted into a transport URI that the target device understands.


#19

@$##$ Samsung. Must be really difficult to demand everything be perfect per their paradigm!


#20

I don't know that the missing content type is the issue or not, one thing you could do is fetch the content type being provided by a uri that does work...


#21

Thanks so much. Need your assistance at some point though.