TTS interface (text to speech)

I know we can set the TTS voice globally, but is there a way to set it "locally" in a rule for example
Something like:
speak "this is a test" using Sally voice or "this is another test" using Matthew voice

P.S. I have both Sonos speaker and Google Home

Yes you can in the code that calls the textToSpeech.

Map textToSpeech(String stringToBeSynthesized, String voice = null)

The English, US voices are:

  • Ivy
  • Joanna
  • Kendra
  • Kimberly
  • Salli
  • Joey
  • Justin
  • Matthew

"In the Code"? I have to write an app?

The only available commands I have are these (Sonos speaker)

No, then. You are sort of out of luck since the Sonos interface does not have a voice parameter input during speak nor playText.

I would put in a feature request for the Capability "SpeechSynthesis" by adding
command "setVoice", [enum]
attribute ttsVoice, "string"

Is there a character limit in what can be said with TTS?

I have a completely random clicking coming from one of my google home speakers (nothing in the logs about it) and about the only way I can get it to stop clicking (without powering it off for an extended period) is I created a virtual switch that makes it speak for a long sentence. After the sentence the speaker usually stops clicking.

Reason I ask for the character limit is this is the rule that the virtual switch runs.

And everytime it stops speaking on the word "This"?

Any ideas?

There is no limit...

Any idea on what could cause it to not complete the words listed in the rule? I tried this on a sonos one as well?

Edit, I turned off the "Stop after TTS Complete" toggle on the driver page, it appears to complete it now.

1 Like

Is there any documentation around which of the SSML tags work with Hubitat and which ones don't? I am tyring to use some of them and they don't seem to be working but other seem to work fine. For example, the <break time="3s"/> works fine but <say-as interpret-as=”ordinal”> does not. The REAL problem I'm running into is that logging does absolutely no good in trying to figure out if these are working correctly or being stripped out. This phrase: This is <break time="3s"/> a test of TTS. on a log, looks like this: This_is__a_test_of_TTS. (substituted underscores for spaces since discourse won't allow you to put two spaces next to each other). It's really a bit of a bugger to figure out.

Any of the embedded tags that poly supports should work.
We don't perform any filtering.


I figured out the problem for some reason the quote marks I copied from one reference source for Amazon Polly did not come through as regular double quotes. It wasn't until I typed it by hand that it worked correctly. The one that didn't work was:
<say-as interpret-as=”ordinal”>52</say-as>
And the one that worked was:
<say-as interpret-as="ordinal">52</say-as>

Very, VERY subbtle difference. It wasn't until I put them side-by-side that I got it to work. Sorry for the confusion.


ahhh yes.. The “pretty” quotes don’t work for code.. That used to drive me bananas when I wasn’t using an ide and copying and pasting..

It's almost impossible to see unless you put them into the right font and right next to each other. I've never run into this before so it wasn't anything I've had to look for. Only spun my wheels on that for half a day. UGH! :angry: lol

1 Like

been there.. Cursing why isn’t this #%*%# code working.. Now I use an IDE that has built-in github integration and supports all the languages I need..

And doesn’t do the pretty quotes

Well, this was typing into the edit device no other real option than Chrome. Not like I was writing code. :slight_smile:

1 Like

Just come over from ST and loving HE. Local execution rules! I am using TTS with RM, passing the text in a string using a custom command and it works well. I am trying to embed a SSML pause as shown above in my TTS but as I save it drops out the command. Is there special syntax? can I use a local variable and concatenate it in? BTW, I have been successful with using a variable to add text, but not with SSML in it

For example, my TTS string is “this is a test” %variable%” and it works if %variable% is text string but I can’t pass “” as it will not save into the variable string.

Any help would be appreciated or a simple nope won’t work, SSML is only for use in code is good as well.

If anyone knows how to do this in RM, @bravenel would know.

You can put "" in a variable:

What you want to do is to get the entire string into a variable, and then use the variable in the speech action. Please show the actual string you want to use.


@bravenel or @mike.maxwell:
Is there any way to query what the current Hubitat system setting is set for the TTS Language? The reasoning behind this is I want to determine what the "native" language for a user is so my driver can query API's with the actual user's language in mind instead of always just getting them US-English data. The TTS Language is more likely to be correct and I was hoping to avoid having another preference for them to have to select (likely I would just leave them stuck with English).

I searched the documentation and forum but did not find any method for that. I did find the getTTSVoices() but that just returns the entire list of possibilities.

There isn't, but we can add one.

1 Like

Do you want me to add a topic in the "Feature Request" section for it? I think it would be handy to have, but I cannot say it is high-priority (at least for me).