GoogleTTS - doesn't play a sound

Version: Openhab 3.1.0
Hardware:
OS: Raspbian Buster v. 10
Installation type: docker container

ExecStart=/usr/bin/docker run --name=%n --tty \
  -v /etc/localtime:/etc/localtime:ro \
  -v /etc/timezone:/etc/timezone:ro \
  -v /opt/openhab/conf:/openhab/conf \
  -v /opt/openhab/userdata:/openhab/userdata \
  -v /opt/openhab/addons:/openhab/addons\
  --add-host "openhab.master:HOST_IP" \
  -p 80:8080 \
  -p 443:8443 \
  -p 5007:5007 \
  --privileged \
  DOCKER_TAG

Google TTS addon is installed and properly configured.
Chromecast devices properly attached (Google Home)

Rule call:

say ("Hello", "googletts:enUSStandardA", "chromecast:chromecast:familyroom")

produces files:

@raspberrypi:/opt/openhab/userdata/cache/org.openhab.voice.googletts $ ls -la
total 64
drwxrwxrwx 2 openhab openhab  4096 Nov 11 16:43 .
drwxr-xr-x 5 openhab openhab  4096 Nov 10 18:44 ..
-rw-r--r-- 1 openhab openhab   105 Nov 11 16:43 enUSStandardA_051aafb04738c9e0022cccf1bcc613c0.txt
-rw-r--r-- 1 openhab openhab 51404 Nov 11 16:43 enUSStandardA_051aafb04738c9e0022cccf1bcc613c0.wav

Unfortunately Google Home is silent (on the beginning sometime pings a bell). Rule log:

2021-11-11 16:43:07.429 [INFO ] [ab.core.model.script.maintenace_rule] - say hello start
2021-11-11 16:43:37.958 [INFO ] [ab.core.model.script.maintenace_rule] - say hello end

It tooks half a minute to call something.

Same situation is calling:

playSound ("chromecast:chromecast:familyroom", "abc.wav")

(abc.wav is renamed Google generated file placed in /opt/openhab/conf/sounds directory)

After copying file to the /opt/openhab/conf/html/sounds instruction (192.168.0.4 is a rpi address):

playStream ("chromecast:chromecast:familyroom", "http://192.168.0.4/static/sounds/abc.wav")

works perfectly.

Is this something misconfigured from my side?

Did you setup the google cloud

Yes, i’ve done setup. As you see wav files are created successfully (as I understand connection myOH3 - cloudOH3 - Google Cloud works ok). Problem is with sharing those files to chromecast devices. It is also properly configured because playStream() works ok.

Ok

Can you confirm billing is setup and the project is in production?

I assume the Google TTS api is installed and activated

Your Chromecast are obviously online

You have setup the voice in setting

You have setup google TTS

Now lets test it.

Create a new rule
Name the rule

Add and Action
Audio and Voice
Add Text
Click on sync to select device
Click done
Save Rule
Now click the blue play triangle to test if it works.

I tried your rule call and it works for me.

Thank you for your assistance.

I followed your instructions. Google billing and account is operational (i see billing information according to my requests with success).

After creation the rule and running it this is exception during first run (no wav files are created):

2021-11-12 17:33:01.076 [ERROR] [ce.googletts.internal.GoogleCloudAPI] - Could not write /openhab/userdata/cache/org.openhab.voice.googletts/enUSStandardA_33c9e5af4e05b6de0e942a019aa586d5.wav to cache
java.io.IOException: java.util.concurrent.ExecutionException: java.io.EOFException: HttpConnectionOverHTTP@1243140::DecryptedEndPoint@124c5fa{l=/172.17.0.4:41086,r=texttospeech.googleapis.com/172.217.16.42:443,OPEN,fill=-,flush=-,to=529239/0}
	at org.openhab.core.io.net.http.HttpUtil.executeUrlAndGetReponse(HttpUtil.java:260) ~[?:?]
	at org.openhab.core.io.net.http.HttpUtil.executeUrl(HttpUtil.java:155) ~[?:?]
	at org.openhab.core.io.net.http.HttpUtil.executeUrl(HttpUtil.java:130) ~[?:?]
	at org.openhab.core.io.net.http.HttpRequestBuilder.getContentAsString(HttpRequestBuilder.java:135) ~[?:?]
	at org.openhab.voice.googletts.internal.GoogleCloudAPI.synthesizeSpeechByGoogle(GoogleCloudAPI.java:425) ~[?:?]
	at org.openhab.voice.googletts.internal.GoogleCloudAPI.synthesizeSpeech(GoogleCloudAPI.java:334) ~[?:?]
	at org.openhab.voice.googletts.internal.GoogleTTSService.synthesize(GoogleTTSService.java:331) ~[?:?]
	at org.openhab.core.voice.internal.VoiceManagerImpl.say(VoiceManagerImpl.java:223) ~[?:?]
	at org.openhab.core.automation.module.media.internal.SayActionHandler.execute(SayActionHandler.java:60) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1183) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1035) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1051) ~[?:?]
	at org.openhab.core.automation.rest.internal.RuleResource.runNow(RuleResource.java:327) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[bundleFile:3.4.3]

    ....


    Caused by: java.util.concurrent.ExecutionException: java.io.EOFException: HttpConnectionOverHTTP@1243140::DecryptedEndPoint@124c5fa{l=/172.17.0.4:41086,r=texttospeech.googleapis.com/172.217.16.42:443,OPEN,fill=-,flush=-,to=529239/0}
	at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:730) ~[bundleFile:9.4.40.v20210413]
	at org.openhab.core.io.net.http.HttpUtil.executeUrlAndGetReponse(HttpUtil.java:251) ~[?:?]
	... 68 more
Caused by: java.io.EOFException: HttpConnectionOverHTTP@1243140::DecryptedEndPoint@124c5fa{l=/172.17.0.4:41086,r=texttospeech.googleapis.com/172.217.16.42:443,OPEN,fill=-,flush=-,to=529239/0}
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:376) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1614) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:259) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:181) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:79) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:131) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:169) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:540) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:395) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:161) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) ~[bundleFile:9.4.40.v20210413]
	... 3 more
2021-11-12 17:33:01.157 [WARN ] [core.voice.internal.VoiceManagerImpl] - Error saying 'Hello Google': Could not read from Google Cloud TTS Service
org.openhab.core.voice.TTSException: Could not read from Google Cloud TTS Service
	at org.openhab.voice.googletts.internal.GoogleTTSService.synthesize(GoogleTTSService.java:333) ~[?:?]
	at org.openhab.core.voice.internal.VoiceManagerImpl.say(VoiceManagerImpl.java:223) ~[?:?]
	at org.openhab.core.automation.module.media.internal.SayActionHandler.execute(SayActionHandler.java:60) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1183) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1035) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1051) ~[?:?]
	at org.openhab.core.automation.rest.internal.RuleResource.runNow(RuleResource.java:327) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[bundleFile:3.4.3]
	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[bundleFile:3.4.3]

    Caused by: java.util.concurrent.ExecutionException: java.io.EOFException: HttpConnectionOverHTTP@1243140::DecryptedEndPoint@124c5fa{l=/172.17.0.4:41086,r=texttospeech.googleapis.com/172.217.16.42:443,OPEN,fill=-,flush=-,to=529239/0}
	at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:730) ~[bundleFile:9.4.40.v20210413]
	at org.openhab.core.io.net.http.HttpUtil.executeUrlAndGetReponse(HttpUtil.java:251) ~[?:?]
	... 68 more
Caused by: java.io.EOFException: HttpConnectionOverHTTP@1243140::DecryptedEndPoint@124c5fa{l=/172.17.0.4:41086,r=texttospeech.googleapis.com/172.217.16.42:443,OPEN,fill=-,flush=-,to=529239/0}
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:376) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1614) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:259) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:181) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:79) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:131) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:169) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:540) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:395) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:161) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) ~[bundleFile:9.4.40.v20210413]
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) ~[bundleFile:9.4.40.v20210413]
	... 3 more
2021-11-12 17:33:01.157 [WARN ] [core.voice.internal.VoiceManagerImpl] - Error saying 'Hello Google': Could not read from Google Cloud TTS Service
org.openhab.core.voice.TTSException: Could not read from Google Cloud TTS Service
	at org.openhab.voice.googletts.internal.GoogleTTSService.synthesize(GoogleTTSService.java:333) ~[?:?]
	at org.openhab.core.voice.internal.VoiceManagerImpl.say(VoiceManagerImpl.java:223) ~[?:?]
	at org.openhab.core.automation.module.media.internal.SayActionHandler.execute(SayActionHandler.java:60) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1183) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1035) ~[?:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runNow(RuleEngineImpl.java:1051) ~[?:?]
	at org.openhab.core.automation.rest.internal.RuleResource.runNow(RuleResource.java:327) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[bundleFile:3.4.3]
	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[bundleFile:3.4.3]

Next runs don’t produce errors in openhab.log. Files are generated now:

pi@raspberrypi:/opt/openhab/userdata/cache/org.openhab.voice.googletts $ ls -la
total 68
drwxrwxrwx 2 openhab openhab  4096 Nov 12 17:48 .
drwxr-xr-x 5 openhab openhab  4096 Nov 10 18:44 ..
-rw-r--r-- 1 openhab openhab   106 Nov 12 17:48 enUSStandardA_33c9e5af4e05b6de0e942a019aa586d5.txt
-rw-r--r-- 1 openhab openhab 53804 Nov 12 17:48 enUSStandardA_33c9e5af4e05b6de0e942a019aa586d5.wav

I’ve checked OpenHAB container ip address:

pi@raspberrypi:~ $ sudo docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 0c1a7d63850e

172.17.0.4

So it looks, that OpenHAB in docker container has problems with connectivity/cross-connectivity. But a little bit strange is, that file is finally donwloaded, but still cannot be sent to chromecast device.

I’ve made several experiments:

  1. Enabled trace logs
openhab> log:set TRACE org.openhab.voice.googletts                                                                                                                              
openhab> log:set TRACE org.openhab.core.auth.oauth2client                                                                                                                       
openhab> log:set TRACE org.openhab.core.audio
openhab> log:set TRACE org.openhab.core.audio.internal.webaudio
  1. Created rule and run it.

  2. First run with the specific content:

2021-12-27 17:15:13.422 [DEBUG] [.googletts.internal.GoogleTTSService] - Synthesize 'It doesn't work' for voice 'googletts:enAUWavenetD' in format AudioFormat [codec=PCM_SIGNED, container=WAVE, bigEndian=true, bitDepth=16, bitRate=705600, frequency=44100]
2021-12-27 17:15:13.432 [DEBUG] [lient.internal.OAuthStoreHandlerImpl] - Decrypting token: AccessTokenResponse [accessToken=<redacted>, tokenType=Bearer, expiresIn=3599, refreshToken=<redatcted>, scope=https://www.googleapis.com/auth/cloud-platform, state=null, createdOn=2021-12-27T16:57:41.954280]
2021-12-27 17:15:13.501 [ERROR] [ce.googletts.internal.GoogleCloudAPI] - Could not write /openhab/userdata/cache/org.openhab.voice.googletts/enAUWavenetD_1b87d05704d12761b0f1da06ee4578a6.wav to cache
  1. Second run of the rule with the same content:
2021-12-27 17:27:56.029 [DEBUG] [.googletts.internal.GoogleTTSService] - Synthesize 'Why it doesn't work' for voice 'googletts:enAUWavenetD' in format AudioFormat [codec=PCM_SIGNED, container=WAVE, bigEndian=true, bitDepth=16, bitRate=705600, frequency=44100]
2021-12-27 17:27:56.037 [DEBUG] [lient.internal.OAuthStoreHandlerImpl] - Decrypting token: AccessTokenResponse [accessToken=<redacted>, tokenType=Bearer, expiresIn=3599, refreshToken=<redacted>, scope=https://www.googleapis.com/auth/cloud-platform, state=null, createdOn=2021-12-27T16:57:41.954280]
2021-12-27 17:27:56.821 [DEBUG] [ce.googletts.internal.GoogleCloudAPI] - Caching audio file enAUWavenetD_321d497d13506188912ad47d56ab0ce1.wav
2021-12-27 17:27:56.827 [DEBUG] [ce.googletts.internal.GoogleCloudAPI] - Caching text file enAUWavenetD_321d497d13506188912ad47d56ab0ce1.txt

In second run files are created in proper location.

However:
5. My Google Home Mini (Chromecast) is not saying anything. Chromcast device (thing) is online.

I’ve done similar experiment with VoiceRSS.

There are two questions:

  1. Why file in cache is created in second run and first is always failing?
  2. What happens during communication between OpenHAB and Chromecast? How to enable TRACE logs for this part of code. And why it doesn’t work?

Has anyone positive experience with running Google TTS on docker instance?

Installation in docker. So parameter

binding.chromecast:callbackUrl=http://192.168.0.1

was required. After that chromecast binding was able to play sound.