[Google TTS] Update README.md (#15637)

* Update README.md

I had some struggles with setting up google TTS, got it to work eventually and now update the README to help users in the future.

This commit includes updating the information, including necessary tips, formatting und some minor details

Signed-off-by: Felix Schneider <fs@felix-schneider.org>
This commit is contained in:
Felix Schneider 2023-10-06 08:25:15 +02:00 committed by GitHub
parent b7ff168b18
commit 0157ebf28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,7 @@ You can find pricing information on the [documentation page](https://cloud.googl
* [Obtaining Credentials](#obtaining-credentials) * [Obtaining Credentials](#obtaining-credentials)
* [Configuration](#configuration) * [Configuration](#configuration)
* [Voice Configuration](#voice-configuration) * [Voice Configuration](#default-text-to-speech-and-voice-configuration)
<!-- /MarkdownTOC --> <!-- /MarkdownTOC -->
@ -20,15 +20,17 @@ You can find pricing information on the [documentation page](https://cloud.googl
Before you can integrate this service with your Google Cloud Text-to-Speech, you must have a Google API Console project: Before you can integrate this service with your Google Cloud Text-to-Speech, you must have a Google API Console project:
* Select or create a GCP project. [link](https://console.cloud.google.com/cloud-resource-manager) 1. Select or create a Google Cloud project ([link](https://console.cloud.google.com/cloud-resource-manager))
* Make sure that billing is enabled for your project. [link](https://cloud.google.com/billing/docs/how-to/modify-project) 2. Make sure that billing is enabled for your project ([link](https://cloud.google.com/billing/docs/how-to/modify-project))
* Enable the Cloud Text-to-Speech API. [link](https://console.cloud.google.com/apis/dashboard) 3. Enable the `Text-to-Speech API` ([link](https://console.cloud.google.com/apis/dashboard))
* Set up authentication: * Don't mistake with the `Speech-to-Text API`
* Go to the "APIs & Services" -> "Credentials" page in the GCP Console and your project. [link](https://console.cloud.google.com/apis/credentials) 4. Set up authentication:
* From the "Create credentials" drop-down list, select "OAuth client ID". 1. Go to the `APIs & Services` -> `Credentials` page in the GCP Console and your project ([link](https://console.cloud.google.com/apis/credentials))
* Select application type "Web application" and enter a name into the "Name" field. 2. From the `Create credentials` drop-down list, select `OAuth client ID`.
* Add "https://www.google.com" to the "Authorized redirect URIs". 3. Select application type `Web application` and enter a name into the `Name` (e.g. `OpenHAB TTS`) field.
* Click Create. A pop-up appears, showing your "client ID" and "client secret". 4. Add `https://www.google.com` to the `Authorized redirect URIs`.
* Watch out for trailing spaces in the URL! E.g. when using the copy url feature in the context menu of Google Chrome it appends a slash (`https://www.google.com` becomes `https://www.google.com`) and the steps afterwards fail.
5. Click Create. A pop-up appears, showing your "client ID" and "client secret".
## Configuration ## Configuration
@ -37,12 +39,12 @@ Using your favorite configuration UI to edit **Settings / Other Services - Googl
* **Client Id** - Google Cloud Platform OAuth 2.0-Client Id. * **Client Id** - Google Cloud Platform OAuth 2.0-Client Id.
* **Client Secret** - Google Cloud Platform OAuth 2.0-Client Secret. * **Client Secret** - Google Cloud Platform OAuth 2.0-Client Secret.
* **Authorization Code** - This code is used once for retrieving the Google Cloud Platform access and refresh tokens. * **Authorization Code** - This code is used once for retrieving the Google Cloud Platform access and refresh tokens.
**Please go to your browser ...** 1. Go to `OAuth consent screen` ([link](https://console.cloud.google.com/apis/credentials/consent)) and set the `publishing status` to `production` to activate the created project.
[https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&prompt=consent&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=<clientId>](https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&prompt=consent&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=<clientId>) (replace `<clientId>` by your Client Id) 2. Wait a few minutes. The step before takes some time to go live. Sometimes it is necessary to wait a few hours, so you can try after some minutes, if it doesn't work, try again the next day.
**... to generate an authorization code and paste it here**. 3. Go to your browser and access the following URL to generate an authorization code
After your browser has been redirected to https://www.google.com, the authorization code will be set in the browser URL as value of the "code" URL query parameter. [https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&prompt=consent&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=<clientId>](https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&prompt=consent&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=CLIENTID) (replace `CLIENTID` at the end by your Client Id)
After initial authorization, this code is not needed anymore. 4. After your browser has been redirected to https://www.google.com, the authorization code will be set in the browser URL as value of the "code" URL query parameter (e.g. `https://www.google.com/?code=XXXXXXXXXX&scope=https://www.googleapis.com/auth/cloud-platform` --> `XXXXXXXXXX`)
It is recommended to clear this configuration parameter afterwards. 5. After initial authorization, this code is not needed anymore. It is recommended to clear this configuration parameter afterwards.
* **Pitch** - The pitch of selected voice, up to 20 semitones. * **Pitch** - The pitch of selected voice, up to 20 semitones.
* **Volume Gain** - The volume of the output between 16dB and -96dB. * **Volume Gain** - The volume of the output between 16dB and -96dB.
* **Speaking Rate** - The speaking rate can be 4x faster or slower than the normal rate. * **Speaking Rate** - The speaking rate can be 4x faster or slower than the normal rate.
@ -75,3 +77,12 @@ In case you would like to setup these settings via a text file, you can edit the
org.openhab.voice:defaultTTS=googletts org.openhab.voice:defaultTTS=googletts
org.openhab.voice:defaultVoice=googletts:XXX org.openhab.voice:defaultVoice=googletts:XXX
``` ```
You can see the available voices by entering `voice voices` in the karaf console
```shell
openhab> voice voices
...
Google Cloud - Deutsch (Deutschland) - de-DE-Standard-C (googletts:deDEStandardC)
...
Google Cloud - Englisch (Vereinigte Staaten) - en-US-Neural2-A (googletts:enUSNeural2A)
...
```