Google TTS, how to change to male voice?

I like to change things up a bit, so I have my TTS configured as basically, whenever a sensor is triggered, "[sensor name] is now [open/closed] / [on/off] with a dropdown menu on my groups page to select which language you want the announcements to play in. Sometimes I’m in an Australian mood, sometimes English…

So i stumbled across this rather old thread because i had hopes to do something similar… looked through the source code and found that the current method of google tts is actually not using the voice/tts api at all. It’s rather cleverly using the translate website to read out the text. No limits that way. That being said the current implementation does not allow for voice selection… if we wanted to use voices though on the actual tts api (https://cloud.google.com/text-to-speech/?hl=en_GB), it is free for the first 4m characters for base voices per month and free for the first 1m characters on the advanced voices per month… if someone were to have the time to dedicate to making a new module that utilizes the google tts api rather than the translate site, we could select the exact voice we all want. (“en-GB-Wavenet-B”)

Would need to set up an api key in the config for each instance… worth it?

6 Likes

This I must admit is amazing and worth dedicating my time to. No idea how long it will take me, but I’m on it.

Yall can try this… works great. Just remember to change your automation.yalm from “tts.google_translate_say” to “tts.google_cloud_say”.

5 Likes

Hi @Jizar_Stoffel

Did you put the credentials json in the config folder of HA?

no, when you set it up on the developer’s page, all you need to do is download the .json they give you and put on your config folder. I believe they use tokens now instead of crendentials.
this is my code on configuration.yalm

tts:
  - platform: google_cloud
    key_file: googlecloud.json
    language: en-US
    gender: female
    voice: en-GB-Wavenet-C
    encoding: linear16
    # speed: 0.9
    # pitch: -2.5
    # gain: -5.0
    profiles:
      - small-bluetooth-speaker-class-device
2 Likes

Hi @Jizar_Stoffel

I got it to work last night - and seems the ‘gender’ is obsolete now, as you choose a voice.
Though, this might be different if you don’t use the advanced neural voices…

Hi,
It’s working great with Google Cloud parameters, but currently I’m stuck with one voice (the one configured in configuration.yaml).
I need to change the language (EN, ES, FR) when running automations, but I didn’t manage dynamically changing the language/voice when calling the tts service.
Did any one manage this ?

Thanks

Go here: https://cloud.google.com/text-to-speech/docs/voices
test the voice you want and change it in your configuration.yaml

tts:
  - platform: google_cloud
    key_file: googlecloud.json
    language: en-US # <<<<<<<<<<< here
    gender: female #<<<<<<<<<<<<<<<< here
    voice: en-US-Wavenet-C #<<<<<<<<<<<<<<<<<< here 
    encoding: linear16
    # speed: 0.9
    # pitch: -2.5
    # gain: -5.0
    profiles:
      - small-bluetooth-speaker-class-device
2 Likes

Hi,
@Jizar_Stoffel I don’t know if your reply was for my question.
Maybe I did not explain myself correctly.

I set it up correctly and can choose a voice, it’s working great.
But I want to change the voice any time I want through automation :

  • Automations for me would be in french for instance
  • I live in Spain, and so I need sometimes to output Spanish message…

Currently I only managed to specify one and only one voice.

Regards.

Hi,

Can you please help me, I think I did everything correctly, but still I don’t get the Dutch voice but the English one :frowning:

I put this in my configuration.yaml file

# Text to speech
# Example configuration.yaml entry
tts:
  - platform: google_cloud
    key_file: googlecloud.json
    language: nl-NL
    gender: female
    voice: nl-NL-Wavenet-D
    encoding: linear16
    speed: 0.9
    pitch: -2.5
    gain: -5.0
    profiles:
      - telephony-class-application
      - wearable-class-device

Copied the json file in my .config folder, restarted HA and still as I use this the language is in English :frowning: anyone who can help me with this please?

Screenshot 2020-03-14 at 18.59.46

I dont think that is possible at the moment, you only get the voice you setup on config.yaml

Need more info in order to help …
but it seems that you want it to use Dutch voices.
You need to set the voice (on config.yalm) to a Dutch voice and set your google devices (on the Google app) to the Dutch language. or it will try to read English as Dutch. All your automation need to also be in Dutch.
With me… if I set my voice to Portuguese and have the Language set to English. every automation I have sounds really strange.

I installed a new version and update my configuration.yaml file to NL and now it works, very strange but it works, so happy :wink: Thanks!

Hi,

i have the same probem.
Please tell new version of what have you installed and how?

Thanks a lot!

The same behavior. Tried to change some languages in .yalm, but it speaks only english (((

Hi guys!

Here is the solution of problem with setting up another language. Read after “PS”
https://community.home-assistant.io/t/tts-queue-in-node-red-for-google-cloud-and-other-tts-engine/214022

I am just getting started with Home Assistant and would like a bit of help. In the above example, do I need to include the “profiles” information? If so, I am not quite sure is required here for me?

Also, I see in some of them the speed, pitch, & gain are commented out. So I am assuming I only need those values if I want to tweak any of those values and that if I am happy with the voice “as is” they values are unneeded.

Thank you.

Any help is greatly appreciated.

Edit: Please disregard - I played around with it for a while and got everything working.

So… I used TTS using google translate. In the dropdown box asking for what language to translate to, I put en-gb. This gives me a female voice that has a british accent. Tried everything else, and nothing else appeared to work.