Google TTS addon for OH2

Tags: #<Tag:0x00007f4337bccee8> #<Tag:0x00007f4337bcce20> #<Tag:0x00007f4337bccd58>

Hey,

I found some spare time and tried to implement a Google TTS addon for OH 2. Something similar had been available for openhab 1 already but never was ported until now.

I opened a pull request on Github, the ci-built jar can be downloaded here.

It’s working fine for me, if you find this interesting and give it a try I’d be curious to hear how it went.

6 Likes

Working for me to with a squeezebox as audio sink.
thx !!

Great. Thanks for reporting back.

Hi André,

I tested this service with Kodi as audio sink and it works very well for me. I’m surprised of the speed especially for cached text / phrases / sentences. Do you have any long-term experience with the size of the googletts/cache/ folder?

One thing I noticed: When you are using different TTS services with several voices you see a very confusing list in e.g. Paper UI or the console (see attached examples). But this is more a problem of the framework not of your implementation - I’ll take care of that.

Console:

openhab> voice voices
googletts:hi GoogleTTS - Hindi
googletts:esUS GoogleTTS - Spanisch (Vereinigte Staaten von Amerika)
googletts:zh GoogleTTS - Chinesisch
googletts:fr GoogleTTS - Französisch
googletts:es GoogleTTS - Spanisch
googletts:ro GoogleTTS - Rumänisch
googletts:no GoogleTTS - Norwegisch
googletts:ko GoogleTTS - Koreanisch
googletts:vi GoogleTTS - Vietnamesisch
googletts:sv GoogleTTS - Schwedisch
googletts:hu GoogleTTS - Ungarisch
googletts:enUS GoogleTTS - Englisch (Vereinigte Staaten von Amerika)
googletts:sq GoogleTTS - Albanisch
googletts:ru GoogleTTS - Russisch
googletts:af GoogleTTS - Afrikaans
googletts:zhTW GoogleTTS - Chinesisch (Taiwan)
googletts:el GoogleTTS - Griechisch
googletts:mk GoogleTTS - Mazedonisch
googletts:nl GoogleTTS - Niederländisch
googletts:enUK GoogleTTS - Englisch (UK)
googletts:sw GoogleTTS - Suaheli
googletts:sk GoogleTTS - Slowakisch
marytts:bits3hsmm bits3-hsmm - Deutsch
googletts:it GoogleTTS - Italienisch
googletts:pt GoogleTTS - Portugiesisch
googletts:cs GoogleTTS - Tschechisch
googletts:ca GoogleTTS - Katalanisch
googletts:sr GoogleTTS - Serbisch
googletts:uk GoogleTTS - Ukrainisch
googletts:ta GoogleTTS - Tamilisch
marytts:bits1hsmm bits1-hsmm - Deutsch
googletts:fi GoogleTTS - Finnisch
googletts:eo GoogleTTS - Esperanto
googletts:da GoogleTTS - Dänisch
googletts:tr GoogleTTS - Türkisch
marytts:cmuslthsmm cmu-slt-hsmm - Englisch (Vereinigte Staaten von Amerika)
googletts:id GoogleTTS - Indonesisch
googletts:la GoogleTTS - Lateinisch
googletts:lv GoogleTTS - Lettisch
googletts:enAU GoogleTTS - Englisch (Australien)
googletts:pl GoogleTTS - Polnisch
googletts:zhCN GoogleTTS - Chinesisch (China)
googletts:hy GoogleTTS - Armenisch
googletts:ja GoogleTTS - Japanisch
googletts:is GoogleTTS - Isländisch
googletts:en GoogleTTS - Englisch
googletts:hr GoogleTTS - Kroatisch
googletts:th GoogleTTS - Thai
googletts:cy GoogleTTS - Walisisch
googletts:ptBR GoogleTTS - Portugiesisch (Brasilien)
googletts:ar GoogleTTS - Arabisch
googletts:bn GoogleTTS - Bengalisch
googletts:esES GoogleTTS - Spanisch (Spanien)
googletts:de GoogleTTS - Deutsch

Paper UI:
Bildschirmfoto%20vom%202018-02-25%2012-18-16_1

Hey @aduffeck,

I have an issue with running your Add-on with the latest snapshot OH2 release:

openhab> bundle:list | grep Google
 17 │ Active    │  80 │ 18.0.0                 │ Guava: Google Core Libraries for Java
 18 │ Active    │  80 │ 3.0.0.v201312141243    │ Google Guice (No AOP)
 87 │ Installed │  80 │ 2.3.0.201802021359     │ Google TTS Voice Service
250 │ Active    │  80 │ 1.12.0.201803291134    │ openHAB Google Calendar
openhab> bundle:start 87
Error executing command: Error executing command on bundles:
        Error starting bundle 87: Could not resolve module: org.openhab.voice.googletts [87]
  Unresolved requirement: Import-Package: org.eclipse.jdt.annotation; resolution:="optional"
  Unresolved requirement: Import-Package: org.eclipse.jetty.util; version="9.3.22"

Any idea how to move forward?

Cheers,
Kuba

1 Like

@aduffeck

Did you see the new Google voice service that was just released with better voices?

Squid

@kubawolanin @KidSquid Yes, I’ve seen the new Google TTS API. When I submitted this addon there only was the unofficial, undocumented Google Translate API that could do TTS. With the release of the official API it is no longer justifiable to misuse the translate service for this purpose, so I will have to retract my submission until I or someone else finds the time to port it to the new API. Unfortunately I’m very busy these days so I won’t make it anytime soon…

If someone’s willing to create a Google Cloud TTS voice add-on, I believe you can use Polly TTS (developed by @hillmanr) as a template:

Good luck!

2 Likes

Did you have found a solution for that. I’ve just upgraded from snapshot 2.2.0 to 2.3.0 and the Google TTS stopped working with the same issue. But it is so much better then VoiceRSS.

1 Like

even im facing the issue after upgrading, can some one fix it

Hi,
I’ve created a service implementation that uses the new Google Cloud TTS API. I’ve been using it for a week now without any problems but it would be good to here your feedback as well to improve the solution.

The pull request can be found here, the binary can be downloaded from here and this is the documentation for setup.
Cheers,
Gabor

1 Like

@gbicskei

This is exciting…thank you for taking the time to work on this.

I’ll test this weekend and report back my findings.

Squid

@gbicskei

FYI - The link you have above for the binary returns a 404 error, I have found the following link on the GitHub page.

Download JAR File Here

Does this require 2.4 or will it work on previous OH 2.x versions?

Thanks Again,

Squid

Sorry, I’ve fixed the link. The jar version is 2.4 but I’ve tested it on 2.3

I get an error when adding json file in PaperUI-voice-google_tts settings.

2018-07-13 20:23:24.856 [ERROR] [b.voice.gtts.internal.GoogleCloudAPI] - Error initializing the service using /var/lib/openhab2/gtts/Google Assistant SDK-83f3efb18d22.json

java.lang.IllegalStateException: Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available

	at io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:256) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:120) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DefaultNettyTransportCreationParamsFilterFactory.<init>(NettyChannelBuilder.java:558) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DefaultNettyTransportCreationParamsFilterFactory.<init>(NettyChannelBuilder.java:551) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.<init>(NettyChannelBuilder.java:489) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:337) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:390) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:206) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:157) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:149) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:151) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.cloud.texttospeech.v1beta1.stub.GrpcTextToSpeechStub.create(GrpcTextToSpeechStub.java:74) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.cloud.texttospeech.v1beta1.stub.TextToSpeechStubSettings.createStub(TextToSpeechStubSettings.java:99) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.cloud.texttospeech.v1beta1.TextToSpeechClient.<init>(TextToSpeechClient.java:128) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at com.google.cloud.texttospeech.v1beta1.TextToSpeechClient.create(TextToSpeechClient.java:109) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at org.openhab.voice.gtts.internal.GoogleCloudAPI.setConfig(GoogleCloudAPI.java:99) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at org.openhab.voice.gtts.internal.GoogleTTSService.updateConfig(GoogleTTSService.java:196) [271:org.openhab.voice.gtts:2.4.0.201807131451]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:229) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:650) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:506) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:307) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:299) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeModifiedMethod(SingleComponentManager.java:772) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.modify(SingleComponentManager.java:727) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:645) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:609) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.configurationUpdated(ConfigurableComponentHolder.java:426) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.RegionConfigurationSupport.configurationEvent(RegionConfigurationSupport.java:284) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.RegionConfigurationSupport$1.configurationEvent(RegionConfigurationSupport.java:89) [32:org.apache.felix.scr:2.0.12]

	at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(ConfigurationManager.java:2090) [8:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:2058) [8:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) [8:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109) [8:org.apache.felix.configadmin:1.8.16]

	at java.lang.Thread.run(Thread.java:748) [?:?]


@sjef86 what OH version are you using? JDK?

Hi,

I’m running openHAB 2.4.0 Build #1310 on a raspberry pi3 (openhabian)…

[20:43:58] openhabian@openHABianPi:~$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) Client VM (build 25.171-b11, mixed mode)

thanks
Christian

Thanks for working on it! Was hoping it would be available!

@sjef86 Thank you for testing! It is very strange, because I just tried the 2.4.0-SNAPSHOT version, and it works fine. The difference is that I’m using the official docker image which is build #1305 and java 1.8.0_144…

@sjef86 It seems that GoogleCloudPlatform / gRPC doesn’t support Raspberry Pi. Check Supported Platforms. This is the same issue that you have…