Amazon Polly speaking tags

Hi!

Following the official Amazon Polly integration docs here Amazon Polly - Home Assistant the service works, in that is successfully speaks words back on the media player I specify, however Polly is reading back everything including the tags such as <speak> and <break>. So as an example I’m hearing “Less than speak greater than Hello”…etc etc

Here is my test code:

    - service: tts.amazon_polly_say
      data_template:
        entity_id: media_player.kitchen_hub
        message: >
          <speak>
          Hello from
          <break time=".9s"/>
          Amazon Polly
          </speak>

Any pointers to where I’m going wrong would be gratefully received!

Thanks

Use text_type: ssml, I guess

Hi all,

ssml breaks my speech engine. weirdly, it worked…once.

tts:
  - platform: google_translate
    cache: true
    cache_dir: /tmp/tts
    time_memory: 300
  - platform: amazon_polly
    aws_access_key_id: !secret awspolly_access
    aws_secret_access_key: !secret awspolly_secret
    region_name: 'us-east-1'
    text_type: ssml #cooment ot this and works
    voice: Brian
    cache: True
    engine: neural

any ideas?

Logger: homeassistant.helpers.script.websocket_api_script
Source: components/amazon_polly/tts.py:183 
First occurred: 13:53:55 (1 occurrences) 
Last logged: 13:53:55

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: An error occurred (InvalidSsmlException) when calling the SynthesizeSpeech operation: Invalid SSML request
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 184, in async_say_handle
    url = await tts.async_get_url_path(
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 372, in async_get_url_path
    filename = await self.async_get_tts_audio(
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 384, in async_get_tts_audio
    extension, data = await provider.async_get_tts_audio(message, language, options)
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 552, in async_get_tts_audio
    return await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/amazon_polly/tts.py", line 183, in get_tts_audio
    resp = self.client.synthesize_speech(
  File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidSsmlException: An error occurred (InvalidSsmlException) when calling the SynthesizeSpeech operation: Invalid SSML request


If it a region issue, perhaps? I’m in Switzerland?

Oh dear, I’m a nooooob!

Here’s the problem (two fold)

  1. I had an error in the yaml for the ssml formatting, so then I jumped over to the the “services” tab in the HA development tools…
  2. trying to debug using “services”, I completely forgot to add the ssml tags to the message. e.g.
<speak>Rob is a noob</speak> 

and then wrongly assumed polly wasn’t working.

Sorry for the noise, but perhaps it might help someone to avoid the same mistake.

1 Like