Google TTS Punctuation, pauses in speech

I know this is first world problem, but I have a Google home and using the TTS function in HA I have various announcements broadcast - which works great. However, some messages are garbled, mainly because of the lack of punctuation in the speech. I have tried full stops, comma’s, semicolons, double commas, but none seem to be reflected by the TTS engine. Is there a way to introduce some pausing into the TTS string?

1 Like

Any luck in this area? Interested in knowing

I’ve done a little experimenting on this and the only perceptible difference I could find was with a comma. But the effect was small and I can’t be 100% certain it is consistent.

While not exactly pleasant. I wonder about putting a sensor or local file for it to read with non-printable characters between sensors words that you want to say. Since google home can’t pronounce non-printable characters.

So maybe a file/sensor with a bunch of ■ characters will work or may not even need that and just put a bunch in the actuall google say.

I hadn’t thought about using non alphabetic characters. I’ll experiment with that. I wouldn’t need to use a sensor, I construct the message dynamically so if I could find a ‘sting’ which caused a pause I could just insert it as appropriate.

(In case you don’t know a ‘?’ seems to stop Google TTS).

EDIT: 5 minutes later, I couldn’t wait :slight_smile: A whole load of these ■ makes no difference.

Interesting also

As this has come back to life…

I can’t remember how I found out but ,. (comma then full stop) seems to give a small but perceptibly longer pause than either a comma or full stop on their own.

I found this problem challenging and wanted to give it a try.

So I made a Node red sequence that takes a message and splits it on . and passes each part to the tts with a delay.
I only have a 500 ms delay to make sure the state changes to “playing”, but if you want then you can add more delay before the message loops.

[{"id":"38eacf1e.26f85","type":"inject","z":"2227cef1.c55b22","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":140,"wires":[["e0cdc2db.0cdcb"]]},{"id":"e0cdc2db.0cdcb","type":"function","z":"2227cef1.c55b22","name":"The message, could be a current state node instead","func":"msg.payload = \"This is a message. With a few sentences. That makes no sense. Or what do you think?\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":140,"wires":[["c8a41850.44dae8"]]},{"id":"4b17a03b.13519","type":"function","z":"2227cef1.c55b22","name":"Split the message","func":"if(Array.isArray(msg.arr) === false){\n    msg.arr = msg.payload.split(\".\")\n}\n\nif(msg.arr.length > 0){\n    msg.payload = {\n        data:{\n        \"entity_id\": \"media_player.kok_mini\",\n        \"message\": msg.arr[0]\n        }\n    }\n    msg.arr.shift();\n}else if(msg.arr.length === 0){\n    msg.payload = \"stop\";\n}\n\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":170,"y":300,"wires":[["c3e50e88.c0ff9","38e9120e.cf6e7e"]]},{"id":"c3e50e88.c0ff9","type":"switch","z":"2227cef1.c55b22","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"stop","vt":"str"},{"t":"neq","v":"stop","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":300,"wires":[[],["6ede005b.f356a"]]},{"id":"e834227.0076ae","type":"delay","z":"2227cef1.c55b22","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":750,"y":300,"wires":[["5073f9fd.67af28"]]},{"id":"6ede005b.f356a","type":"api-call-service","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.kok_mini","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":540,"y":300,"wires":[["e834227.0076ae"]]},{"id":"38e9120e.cf6e7e","type":"debug","z":"2227cef1.c55b22","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":240,"wires":[]},{"id":"5073f9fd.67af28","type":"ha-wait-until","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","outputs":1,"entityId":"media_player.kok_mini","entityIdFilterType":"exact","property":"state","comparator":"is","value":"idle","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":900,"y":300,"wires":[["4b17a03b.13519"]]},{"id":"c8a41850.44dae8","type":"api-call-service","z":"2227cef1.c55b22","name":"Empty message","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.kok_mini","data":"{\"entity_id\":\"media_player.kok_mini\",\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":740,"y":140,"wires":[["4b17a03b.13519"]]},{"id":"4bbca37b.1700ec","type":"server","z":"","name":"Home Assistant","addon":true}]

Noticed I had to add a empty tts message before the real message to get from media_player off, to idle.

I have a hard time understanding why Google hasn’t come up with a solution for this. I found this same conversation in several places while looking for a solution myself. Two, three years on and they still haven’t come up with anything. It should be simple, make some obscure character = 100ms pause. They obviously have something similar in place commas and periods.

1 Like