textToSpeech()?

Is there a textToSpeech() function available?

I’ve tried:

def sound = textToSpeech("Hello World")
def sound = textToSpeech("Hello World", "Salli")  //Where Salli = the selected voice. 
sound.duration //duration of the sound sample
sound.uri //file or web location of the sound sample converted

These would be used with device playTrack(), playTrackAndRestore(), and playTrackAndResume() functions.

ST uses Amazon Polly for TTS conversion, I wasn’t sure if Hubitat had a local TTS engine or perhaps similar is coming in the future?

Not yet. It’s on the roadmap.

2 Likes

Continuing the discussion from Hub Update 1.0.8:

How do we use this function added in 1.0.8? textToSpeech(). Currently in the ST platform I call the following:

state.sound = textToSpeech(phrase instanceof List ? phrase[0] : phrase, myVoice)

Where phrase = the text that I want to speak.
Where myVoice = the voice name as listed in the Amazon Polly API.

state.sound is then set with the following properties:
state.sound.uri = path to the produced mp3
state.sound.duration = duration of the mp3

See discussion here

Thanks. It looks like it doesn't support custom voices yet textToSpeech(phrase,voice). (It looks like Hubitat is using Google Translate to do the TTS which doesn't support voices as far as I know; This is what ST used before they started hitting quotas and was blocked before moving to Amazon Polly).

textToSpeech(phrase) did produce an MP3 stored on my local Hubitat. If I copy/paste the URL into a browser it plays.

I'm currently using VLCThing as my mediaPlayer device which is producing an error that I am about to dive into:
No signature of method: java.lang.String.call() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.Long, java.util.LinkedHashMap) values: [http://10.x.x.x:8080/tts/7d3c8f5e7e5494bea7aa3b9987ef7f42.mp3, ...] Possible solutions: wait(), any(), trim(), dump(), split(), grep() on line null

Selection of voices is being discussed as a location / setting parameter and not something that can be set at mp3 generation time.

We are using Polly, we are likely going to add an additional optional parameter to specify voice selection.

3 Likes

@mike.maxwell Sorry to bump a fairly old thread, but did this feature get released? If so, can you point me in the direction for specifying voice selection?

They invoked it for system-wide support within Settings - Hub Details - Default Text To Speech (TTS) Voice. It works great.

1 Like

Download the Hubitat app