Google Cloud Platform SSML support - solved

any change we can get SSML support for Google Cloud Platform Text-to-Speech?

Hi

I managed to get it working by downloading google_cloud from git and placed it in custom_components and then changed the following line in tts.py:

synthesis_input = texttospeech.types.SynthesisInput(text=message)

to:

synthesis_input = texttospeech.types.SynthesisInput(ssml=message)

Now I can use SSML <speak> tags and if you donā€™t use SSML tags it works as normal.

2 Likes

thank you very much. It worked great. I just donā€™t understand why it is not officially supported by HA but Amazon polly is?

1 Like

Do you happend to have the link to that?

github main Home assistant rep. in the components folder.

here is the link

1 Like

Okay, this is helpful, but I want to clarify ā€¦ Do I need to declare it somewhere in the configuration.yaml as a custom component now or does HA automatically know to reference the custom_component version over the built in if it exists?

No need, HA always runs custom_component first.

1 Like

This is great!! And indeed, why isnā€™t it implemented by default, its a 4 character changeā€¦ :wink:

I have downloaded the google_cloud into the custom_components folder and made the necessary edits.

Will someone kindly provide an example of how to use it?

Thanks. Will try it out.

For clarification:

  1. Go to https://github.com/home-assistant/core > click the green code button > Download Zip
  2. Unzip the file and copy the core/homeassistant/components/google_cloud folder into <ha_config_folder>/custom_components/google_cloud
  3. Open <ha_config_folder>/custom_components/google_cloud/tts.py and replace the line:
    synthesis_input = texttospeech.types.SynthesisInput(text=message)
    with:
    synthesis_input = texttospeech.types.SynthesisInput(ssml=message)
  4. Reboot Home-assistant
  5. Test it out in Develper Tools > Services
service: tts.google_cloud_say
  entity_id: media_player.<your media player>
  message: <speak>hello</speak>
1 Like

Seems to be that 115.5 has broken the ssml. Iā€™ve used it without problems till 115.0ā€¦

Saw something on GitHub but the solution seems to be stuck in some approval???
I hope it will be fixed soon as the workaround triggers errors after it worked for a short period.

Pull request : Add google cloud tts SSML + fix by lufton Ā· Pull Request #40203 Ā· home-assistant/core Ā· GitHub has been merged.

You can now simply add text_type: ssml in your google_cloud configuration.