Homey Community Forum

Google Services - App for Translate and new Text-to-Speech for any device with speaker output and url input

Now Live!

Use the newest Google Cloud Services, starting with the new Text-to-Speech and Translate.


Translate
U can make a Google Translate device and use it as a condition to translate, of which the transalation will be available as a tokenvalue of the device.

For this you will need the below descripted JSON and setup the API at Setup  |  Cloud Translation  |  Google Cloud

image

Text-To-Speech
Useable with each device that takes an URL.

Cloud devices:
All languages that Google supports, are supported, because the settings are build from live data, so when a new language becames available, it will be for this App also.
Currently you can only set the Voice in the settings, but it will be setable per device in the near future.
You can set Pitch and Speed per device (will be overruled by flows with pitch and/or speed).

SSML coding is accepted now, like: <speak>Here are <say-as interpret-as=“characters”>SSML</say-as> samples.<break time=“3s” />. And continue</speak>

You get a URL for the audio that will be streamed through Homey, so the device eventually playing the mp3 file should be in the same network and have access.

The last 100 transcripts are stored in Homey’s Memory for speed and less requests to Google Cloud (restart of app or Homey means reset of memory).

Create a House device that triggers all applicable devices to say “Dinner is ready!” or just a device for the main room to say “The doorbell is ringing”.
You can add “devices” as many times as you would like, each with its own trigger.

Conditions are also available! You can let a flow wait in de condition till speech is finished before turning to the Then part of the flow.

This works great with other Apps like Sonos (Play Audio Clip), Samsung Smart TV (Launch Browser with URL), Sonos Say (Url) and IFTTT.

For this you wil need to generate your own Google Cloud Service Account at

and fill-in the JSON in the settings.
Also you need to activate/add the “Cloud Text-to-Speech API” library in cloud.google.com.
In total, above is the same as step 1 , 2, 3, and 4 of Quickstart: Using the client libraries

Easiest way to enter the JSON in the settings would be throught the developer site: Homey Developer - App Settings

It’s free upto 4 million characters per month for non-Wavenet voices AND 1 million characters per month for Wavenet voices.

To see how many characters you have used up, goto the Google Cloud Console homepage, and to the right click on View detailed charges (the filter Group By SKU should be on)
As of release 1.6.3, if everything is set correctly, but during translation an error is given by Google Cloud, the message wil me given as notification.
Bandwidth excausted, meaning quota reached, is useally not about the monthly quota, but the minutes quota which you can set yourself in you own Google Cloud Console (account).

There is the also old Google TTS device, with a max. 200 characters and limited options.
You do not need a Google Cloud account for that.

These languages are currently supported in Non-Cloud:
Engels (GB)
English (US)
Dutch (NL)
Dutch (BE)
German (DE)
German (LU)
French (FR)
French (BE)
Spanish (ES)
Italian (IT)
Swedish (SV)
Norwegian (NO)

Wanna play it on Homey?
Music Url Converter - Play Music URL’s on Homey bigger then 900 KB - Apps - Homey Community Forum (athom.com)

This works great voor a PA system:
How to make a Great Public Announcement (PA) System with any device! - Apps - Homey Community Forum (athom.com)

Step 1
Create a Google TTS Cloud Device.
In Homey, create a Device, select the Google Service App and then select the Text-ToSpeech device.

Step 2
Setup a trigger for the TTS Device with a actioncard that send the Url token to the device you want to hear to voice on.
image

Step 3
Start a speech condition/action (And or Then part) with a text (and it wil trigger the flow from step 2)
image

13 Likes

This looks really interesting! I imagine the quality of the voice is so much better than the regular one.
Usecase for me would also be a couple of preset voice messages to send as a notification on Google speakers or other devices. Given the buffering of the last 100 messages this will really decrease the load. Will try this once it is deployed :slight_smile:

Indeed, the voices are much better, especially the Wavenet voices. And I’m using NL_MALE_C wavenet atm, and it is very nice.
Also, being able to write SSML makes it much more realistic, for example, when writing paragraphs with sentences like
<p><s>hello</s><s>I hope you are doing fine today</s><s>see you later</s></p>,
The pauses between does sentences are variable, much more intuitive the putting breaks of 0.5 or 1 seconds after each sentence. And a million characters a month is quite a lot I reckon.
But I am indeed planning on improving and making stuff settable that wil reduce google requests overal, make de memory usages started to save does precious monthly characters :wink:

How far away are you from getting the audio to play on Homey itself? :slight_smile:

So I am for one very interested in this application. Hope the app will be available soon

I already have the functionality ready in another app, but I wanna make it smart, so it won’t kill homey’s bandwidth or anything.
And I’m waiting for the publish to go through, then I’ll work on adding the homey as output setting in.

Same here, just waiting for approval :slight_smile:

1 Like

As soon as this comes only you can play it on homey :slight_smile:

Music Url Converter - Play Music URL’s on Homey bigger then 900 KB - Apps - Homey Community Forum (athom.com)

1 Like

Now included: Google Translate

Great!!!Some news when the app will be ready for public download?Thanks

Its live now!

The app is installed.
The Json file is correct
I have select a voice.

I dont understand how i can do something simple as sending the text Dinner is Ready to a Google Chromecast speaker. Do you have a flow example voor me?

Does the Chromecast App have a ActionCard for sending a URL to the device?
If so:

  1. Create a Google TTS Cloud Device
  2. Create a flow with a trigger Url Triggered from the Google TTS Device, and have that flow send the token Url from that trigger (within the flow) to the Chromecast device.
  3. Create a flow to speak, using a conditioncard (an And card) or a actioncard (a Then card) to start speech for that Google TTS Device.

Step 1
Create a Google TTS Cloud Device.
I call it TTS Sonos 1 in this example.

Step 2
Setup a trigger for the TTS Device with a actioncard that send the Url token to the device you want to hear to voice on.
image

Step 3
Start a speech condition/action (And or Then part) with a text (and it wil trigger the flow from step 2).
image

1 Like

Hi Arie,
sorry, but I don’t understand how to manage the second flow.
I have the problem that TTS keeps repeating itself. Also it takes about 3-4 seconds for the voice output to start.
To understand it better, would you also please post the second flow completely.

Btw, do I have to activate the OAuth-Consent Screen? I only have rights for the user type “External”, is that ok?

Hey,

I updated the example i gave above (and the topic main text also) to better show the flows.

If you are using the Athom Sonos App, use Play Audio Clip. This is the new improved version of Send URL, and it works much faster.

In the device settings you can finetune the delay, with Sonos App (URL) you need about 4sec indeed, but with play Audio Clip its about 1 sec or 1.5 seconds. (Default setting is 1000ms).
This delay is included in the time to trigger the Url Finished Trigger Card which can be used to turn the Sonos device back to previous state.

No you don’t need a OAuth-Consent Screen, just a Service Account JSON, with viewing rights to the api’s you use (Text-To-Speech and perhaps Translate). But easier is it to make the Service Account projectmanager like in the Google Setup example given above. Then you don’t need to worry about further rights every time, only enable the right API’s.

Since the Google Cloud Services used (right now) are not linked to a person there is no need (or ability) to connect it to a OAuth (which is used to connect a service including/requesting a specific user). OAuth would be required for youtube searches (linked to you search account) or Speech-To-Text (used to better understand the specific user that is going to be talking).

If you have another quistion i’ll be glad to help.
Let me know if you get it working or not.

1 Like

Thx for all the help.
But still i can not get speech working on a Chromecast Speaker. (google home max, or mini)
I hear the sound that the speaker is triggerd. But no sound.

I hope that some can help me.

unfortunately I don’t have a Chromecast device.
If you send the URL as notification (or save in variable) and you play it yourself through a browser like chrome, does it work?
Does Chromecast have acces to the same network as Homey?

The source is on bitbucket, if someone with a Chromedevice has the same issues and can debug (or even fix) i would be happy to try and solve it, if it is a issue with my app.

I just checked the sourcecode for com.google.ChromeCast on GitHub, and the OnCastWebsite, which you should be able to trigger through a Action Card “Cast Website”, send it as a audio/mp3, just as it should be.

Have you tried Cast Website with the Url token?

Disclaimer: This comment is based purely on reading the source for ChromeCast. :wink:

Now it works flawlessly, and the voice output is also much faster. :+1:t3:
Thank you very much!

I don’t understand how create a google cloud device…:cry: