[APP][Pro] Google Services - App for Translate and new Text-to-Speech for any device with url input

Update: Added a YouTube device to search YouTube
Update: Added Volume Gain and Device Profile to CloudTTS device settings
Update: Added prefix-pause and suffix-pause to CloudTTS device settings (for Chromecast users)

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

See steps below for how to get the JSON.


YouTube
You can make a YouTube device and use it to search video’s.
Currently it will trigger the YouTube device trigger with the first found result.
More functionalities, like playing lists, will be added.


Translate
You 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.

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.
You can set the Voice in the settings, but also within (certain) flowcards.
You can set Pitch, Speed, Volume Gain and Device Profile per device (will be overruled by flows with pitch and/or speed).

Also you can add a prefix and/or suffix pause in the device settings, which is particularly useful for Chromecast users:
A pause added the beginning will separate the notification sound and the actual speech.

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 (with volume)), Samsung Smart TV (Launch Browser with URL), Sonos Say (Url) and IFTTT.

How to get the Google Cloud Service Account (JSON)?

To use this app you will need to do the following:

  1. In the Cloud Console, go to the Create service account page.Go to Create service account
  2. Select a project.
  3. In the Service account name field, enter a name. The Cloud Console fills in the Service account ID field based on this name.In the Service account description field, enter a description. For example, Service account for quickstart .
  4. Click Create .
  5. Click the Select a role field.Under Quick access , click Basic , then click Owner .
  6. Click Continue .
  7. Click Done to finish creating the service account.Do not close your browser window. You will use it in the next step.

Create a service account key:

  1. In the Cloud Console, click the email address for the service account that you created.
  2. Click Keys .
  3. Click Add key , then click Create new key .
  4. Click Create . A JSON key file is downloaded to your computer.
  5. Click Close .

Easiest way to enter the JSON in the settings would be throught the developer site: Homey Developer - App Settings.
Open the Google Service Settings and copy/paste the whole JSON text into the JSON field.

For YouTube you will need to generate an API key and set it in the 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).

You can set the quota’s in the Google Cloud Console. You have to look for it. There are 2 global quota’s: 300 requests per minute, and 150.000 chars per minute.
BUT
There is also a 300 limit chars per minute during your trial account.
You can freelly upgrade to a full account, which will remove the 300 characters a minute and enforce the global 300req/p/m en 150k.char p/min.


Old Google TTS
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 itself?
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 ¶ 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

Please report issues or feature requests at QlusterIT / nl.qluster-it.GoogleServices/ issues — Bitbucket.


Apps:

Donations or Sponsorship

15 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 those sentences are variable, much more intuitive than 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 the memory usage smarter to save those 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 online 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: