Amazon Polly

The amazon_polly text-to-speech platform that works with Amazon Polly to create the spoken output. Polly is a paid service via Amazon Web Services. There is a free tier for the first 12 months and then a charge per million characters afterwards.

Setup

For more information, please read the AWS General Reference regarding Security Credentials to get the needed details. Also, check the boto3 Documentation about the profiles and the AWS Regions and Endpoints Reference for available regions.

Available voices are listed in the Amazon Documentation.

Configuration

To get started, add the following lines to your configuration.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file (example for Amazon Polly). 在更改了configuration.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] 文件后,重启 Home Assistant 以应用更改。 该集成现在显示在集成页面的 设置 > 设备与服务 下。其实体在集成卡片上以及实体标签上列出。

# Example configuration.yaml entry
tts:
  - platform: amazon_polly
    aws_access_key_id: AWS_ACCESS_KEY_ID
    aws_secret_access_key: AWS_SECRET_ACCESS_KEY

Configuration Variables

aws_access_key_id string Required

Your AWS Access Key ID. If provided, you must also provide an aws_secret_access_key and must not provide a profile_name.

aws_secret_access_key string Required

Your AWS Secret Access Key. If provided, you must also provide an aws_access_key_id and must not provide a profile_name.

profile_name string (Optional)

A credentials profile name. If provided, you must not provide an aws_access_key_id nor an aws_secrete_access_key.

region_name string (Optional, default: us-east-1)

The region identifier to connect to.

text_type string (Optional, default: text)

Whether to interpret messages as text or as ssml by default.

voice string (Optional)

The Voice Name/ID to be used for generated speech by default.

output_format string (Optional, default: mp3)

Override the default output format. Either mp3, ogg_vorbis or pcm.

sample_rate string (Optional)

Override the default sample rate. Possible values are: 8000, 16000, 22050, 24000.

Default:

22050 for MP3 and Ogg Vorbis, 16000 for pcm

engine string (Optional, default: standard)

Override the default engine. Can be either of standard, neural, long-form or generative. See Amazon documentation for compatible regions and voices.

Usage

Say to all media_player device entities:

- action: tts.amazon_polly_say
  data:
    message: "<speak>Hello from Amazon Polly</speak>"

or

- action: tts.amazon_polly_say
  data:
    message: >
      <speak>
          Hello from Amazon Polly
      </speak>

Say to the media_player.living_room device entity:

- action: tts.amazon_polly_say
  target:
    entity_id: media_player.living_room
    message: >
      <speak>
          Hello from Amazon Polly
      </speak>

Say with break:

- action: tts.amazon_polly_say
  data:
    message: >
      <speak>
          Hello from
          <break time=".9s" />
          Amazon Polly
      </speak>

Say with specific voice and engine as options:

- service: tts.amazon_polly_say
  data:
    message: "Hello from Amazon Polly"
    entity_id: media_player.living_room
    language: en-GB
    options:
      voice: Amy
      engine: generative

Advanced usage

Amazon Polly supports accented bilingual voices and you may find that you’d prefer the voice you like be slowed down, or speeded up. If the speed of the voice is a concern, Amazon Polly provides the ability to modify this using SSML tags. First enable SSML in configuration:

  - platform: amazon_polly
    ...
    text_type: ssml
    ...

Note: You now need to enclose all new and previous TTS input within the <speak></speak> tags. To use SSML in automation, you can follow these steps, for instance:

action: tts.amazon_polly_say
data:
  cache: true
  entity_id: media_player.mpd
  message: >-
    <speak> <prosody rate="75%">나는  <prosody rate="75%">천천히</prosody> <lang
    xml:lang="fr-FR">parle</lang>.하고 있다식기세척!</speak>
  language: ko-KR