Camel Components

AWS Polly

Since Camel 4.18

Only producer is supported

The AWS2 Polly component supports text-to-speech synthesis using the AWS Polly service. AWS Polly is a cloud service that converts text into lifelike speech.

Prerequisites

You must have a valid Amazon Web Services developer account, and be signed up to use Amazon Polly. More information is available at Amazon Polly.

URI Format

aws2-polly://label[?options]

You can append query options to the URI in the following format:

?options=value&option2=value&…​

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The AWS Polly component supports the following options which are listed below.

Name Description Default Type

configuration (producer)

The configuration that the endpoints of this component start from. Each endpoint gets a copy of it, and the options of the endpoint replace its values.

Polly2Configuration

engine (producer)

The engine that synthesizes the speech: standard, neural, long-form or generative. The voice must support it. For synthesizeSpeech and startSpeechSynthesisTask, Amazon Polly uses the standard engine when neither this option nor the CamelAwsPollyEngine header is set; for describeVoices it only lists the voices that support this engine. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • standard

  • neural

  • long-form

  • generative

  • null

Engine

languageCode (producer)

A language code such as en-US or hi-IN. For synthesizeSpeech and startSpeechSynthesisTask, it selects the language of a bilingual voice, such as Aditi for en-IN or hi-IN, and if not set the voice speaks its default language; for describeVoices, it only lists the voices of this language. The CamelAwsPollyLanguageCode header is used only when this option is not set, and neither is used when pojoRequest is true.

String

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

lexiconContent (producer)

The pronunciation lexicon that putLexicon stores, as a PLS (Pronunciation Lexicon Specification) XML document. A lexicon with the same name in the region is replaced. When neither this option nor the CamelAwsPollyLexiconContent header is set, the body is used. It is not used when pojoRequest is true.

String

lexiconName (producer)

The name of the pronunciation lexicon for getLexicon, putLexicon and deleteLexicon, which fail when neither this option nor the CamelAwsPollyLexiconName header is set. The name is a case-sensitive alphanumeric string of up to 20 characters. The header is used only when this option is not set, and neither is used when pojoRequest is true.

String

lexiconNames (producer)

A comma-separated list of up to 5 names of pronunciation lexicons, stored with putLexicon, that Amazon Polly applies during synthesizeSpeech and startSpeechSynthesisTask. A lexicon applies only when its language is the language of the voice. The CamelAwsPollyLexiconNames header is used only when this option is not set, and neither is used when pojoRequest is true.

String

operation (producer)

Required The operation that the producer performs. The CamelAwsPollyOperation header replaces this option.

Enum values:

  • synthesizeSpeech

  • describeVoices

  • listLexicons

  • getLexicon

  • putLexicon

  • deleteLexicon

  • startSpeechSynthesisTask

  • getSpeechSynthesisTask

  • listSpeechSynthesisTasks

synthesizeSpeech

Polly2Operations

outputFormat (producer)

The format of the output of synthesizeSpeech and startSpeechSynthesisTask: mp3, ogg_vorbis, ogg_opus, pcm (signed 16-bit, mono, little-endian), mulaw or alaw for audio, or json for speech marks. The component cannot set the speech mark types that json needs, so use a request of the AWS SDK with pojoRequest=true for speech marks. When neither this option nor the CamelAwsPollyOutputFormat header is set, mp3 is used. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • json

  • mp3

  • ogg_opus

  • ogg_vorbis

  • pcm

  • mulaw

  • alaw

  • null

OutputFormat

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

pojoRequest (producer)

Whether the body is the request of the AWS SDK for the operation, such as a SynthesizeSpeechRequest for synthesizeSpeech. If true, the producer sends that request as it is, without the options and headers of the operation, and a body of another type fails. Use it for the request fields that the component does not set, such as the speech mark types. If false, the producer builds the request from the options, the headers and the body.

false

boolean

region (producer)

The AWS region of Amazon Polly, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. Lexicons and speech synthesis tasks are kept per region, and Amazon Polly is not available in every region.

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

s3Bucket (producer)

The name of the Amazon S3 bucket in which startSpeechSynthesisTask stores the output file, which fails when neither this option nor the CamelAwsPollyS3Bucket header is set. The header is used only when this option is not set, and neither is used when pojoRequest is true.

String

s3KeyPrefix (producer)

The prefix of the Amazon S3 key of the output file of startSpeechSynthesisTask, to which Amazon Polly adds the task ID and the file extension: the output URI of the returned task gives the full location. The CamelAwsPollyS3KeyPrefix header is used only when this option is not set, and neither is used when pojoRequest is true.

String

sampleRate (producer)

The sample rate of the audio in Hz, as a string, for synthesizeSpeech and startSpeechSynthesisTask: 8000, 16000, 22050 or 24000 for mp3 and ogg_vorbis (also 44100 and 48000 for synthesizeSpeech), 8000 or 16000 for pcm, 48000 for ogg_opus and 8000 for mulaw and alaw. If not set, Amazon Polly uses 22050 for the standard engine and 24000 for the other engines with mp3 and ogg_vorbis, and 16000 with pcm. The CamelAwsPollySampleRate header is used only when this option is not set, and neither is used when pojoRequest is true.

String

snsTopicArn (producer)

The ARN of the Amazon SNS topic to which Amazon Polly sends the status notifications of a task of startSpeechSynthesisTask. If not set, no notification is sent. The CamelAwsPollySnsTopicArn header is used only when this option is not set, and neither is used when pojoRequest is true.

String

taskId (producer)

The ID of the speech synthesis task to get with getSpeechSynthesisTask, which fails when neither this option nor the CamelAwsPollyTaskId header is set. startSpeechSynthesisTask sets that header, but this option, when set, is used instead of it. Amazon Polly keeps a task for 72 hours. It is not used when pojoRequest is true.

String

textType (producer)

Whether the text of the body is plain text (text) or SSML (ssml), for synthesizeSpeech and startSpeechSynthesisTask. SSML must be valid, well-formed SSML in a speak element. When neither this option nor the CamelAwsPollyTextType header is set, text is used. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • ssml

  • text

  • null

TextType

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

voiceId (producer)

The ID of the voice that speaks the text, such as Joanna or Matthew, for synthesizeSpeech and startSpeechSynthesisTask, which fail when neither this option nor the CamelAwsPollyVoiceId header is set. The voice must support the engine of the request: describeVoices lists the voices and their engines. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • Aditi

  • Amy

  • Astrid

  • Bianca

  • Brian

  • Camila

  • Carla

  • Carmen

  • Celine

  • Chantal

  • Conchita

  • Cristiano

  • Dora

  • Emma

  • Enrique

  • Ewa

  • Filiz

  • Gabrielle

  • Geraint

  • Giorgio

  • Gwyneth

  • Hans

  • Ines

  • Ivy

  • Jacek

  • Jan

  • Joanna

  • Joey

  • Justin

  • Karl

  • Kendra

  • Kevin

  • Kimberly

  • Lea

  • Liv

  • Lotte

  • Lucia

  • Lupe

  • Mads

  • Maja

  • Marlene

  • Mathieu

  • Matthew

  • Maxim

  • Mia

  • Miguel

  • Mizuki

  • Naja

  • Nicole

  • Olivia

  • Penelope

  • Raveena

  • Ricardo

  • Ruben

  • Russell

  • Salli

  • Seoyeon

  • Takumi

  • Tatyana

  • Vicki

  • Vitoria

  • Zeina

  • Zhiyu

  • Aria

  • Ayanda

  • Arlet

  • Hannah

  • Arthur

  • Daniel

  • Liam

  • Pedro

  • Kajal

  • Hiujin

  • Laura

  • Elin

  • Ida

  • Suvi

  • Ola

  • Hala

  • Andres

  • Sergio

  • Remi

  • Adriano

  • Thiago

  • Ruth

  • Stephen

  • Kazuha

  • Tomoko

  • Niamh

  • Sofie

  • Lisa

  • Isabelle

  • Zayd

  • Danielle

  • Gregory

  • Burcu

  • Jitka

  • Sabrina

  • Jasmine

  • Jihye

  • Ambre

  • Beatrice

  • Florian

  • Lennart

  • Lorenzo

  • Tiffany

  • Arjun

  • Carlos

  • Carolina

  • Curtis

  • Hyunduk

  • Kenneth

  • Kiara

  • Leo

  • Nate

  • Tina

  • null

VoiceId

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

pollyClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.polly.PollyClient, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. The endpoint does not close a client that is set or autowired.

PollyClient

healthCheckConsumerEnabled (health)

Used for enabling or disabling all consumer based health checks from this component.

true

boolean

healthCheckProducerEnabled (health)

Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true.

true

boolean

proxyHost (proxy)

The host name of the proxy that the HTTP client of Amazon Polly connects through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP client of Amazon Polly connects through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP client of Amazon Polly uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless pollyClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

profileCredentialsName (security)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless pollyClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails.

String

trustAllCertificates (security)

Whether the HTTP client of Amazon Polly trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

useDefaultCredentialsProvider (security)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (security)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Endpoint Options

The AWS Polly endpoint is configured using URI syntax:

aws2-polly:label

With the following path and query parameters:

Path Parameters

Name Description Default Type

label (producer)

Required A logical name of the endpoint, which you choose freely. The producer does not use it: the operation and its input are given by the options, the headers and the body.

String

Query Parameters

Name Description Default Type

engine (producer)

The engine that synthesizes the speech: standard, neural, long-form or generative. The voice must support it. For synthesizeSpeech and startSpeechSynthesisTask, Amazon Polly uses the standard engine when neither this option nor the CamelAwsPollyEngine header is set; for describeVoices it only lists the voices that support this engine. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • standard

  • neural

  • long-form

  • generative

  • null

Engine

languageCode (producer)

A language code such as en-US or hi-IN. For synthesizeSpeech and startSpeechSynthesisTask, it selects the language of a bilingual voice, such as Aditi for en-IN or hi-IN, and if not set the voice speaks its default language; for describeVoices, it only lists the voices of this language. The CamelAwsPollyLanguageCode header is used only when this option is not set, and neither is used when pojoRequest is true.

String

lexiconContent (producer)

The pronunciation lexicon that putLexicon stores, as a PLS (Pronunciation Lexicon Specification) XML document. A lexicon with the same name in the region is replaced. When neither this option nor the CamelAwsPollyLexiconContent header is set, the body is used. It is not used when pojoRequest is true.

String

lexiconName (producer)

The name of the pronunciation lexicon for getLexicon, putLexicon and deleteLexicon, which fail when neither this option nor the CamelAwsPollyLexiconName header is set. The name is a case-sensitive alphanumeric string of up to 20 characters. The header is used only when this option is not set, and neither is used when pojoRequest is true.

String

lexiconNames (producer)

A comma-separated list of up to 5 names of pronunciation lexicons, stored with putLexicon, that Amazon Polly applies during synthesizeSpeech and startSpeechSynthesisTask. A lexicon applies only when its language is the language of the voice. The CamelAwsPollyLexiconNames header is used only when this option is not set, and neither is used when pojoRequest is true.

String

operation (producer)

Required The operation that the producer performs. The CamelAwsPollyOperation header replaces this option.

Enum values:

  • synthesizeSpeech

  • describeVoices

  • listLexicons

  • getLexicon

  • putLexicon

  • deleteLexicon

  • startSpeechSynthesisTask

  • getSpeechSynthesisTask

  • listSpeechSynthesisTasks

synthesizeSpeech

Polly2Operations

outputFormat (producer)

The format of the output of synthesizeSpeech and startSpeechSynthesisTask: mp3, ogg_vorbis, ogg_opus, pcm (signed 16-bit, mono, little-endian), mulaw or alaw for audio, or json for speech marks. The component cannot set the speech mark types that json needs, so use a request of the AWS SDK with pojoRequest=true for speech marks. When neither this option nor the CamelAwsPollyOutputFormat header is set, mp3 is used. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • json

  • mp3

  • ogg_opus

  • ogg_vorbis

  • pcm

  • mulaw

  • alaw

  • null

OutputFormat

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

pojoRequest (producer)

Whether the body is the request of the AWS SDK for the operation, such as a SynthesizeSpeechRequest for synthesizeSpeech. If true, the producer sends that request as it is, without the options and headers of the operation, and a body of another type fails. Use it for the request fields that the component does not set, such as the speech mark types. If false, the producer builds the request from the options, the headers and the body.

false

boolean

region (producer)

The AWS region of Amazon Polly, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. Lexicons and speech synthesis tasks are kept per region, and Amazon Polly is not available in every region.

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

s3Bucket (producer)

The name of the Amazon S3 bucket in which startSpeechSynthesisTask stores the output file, which fails when neither this option nor the CamelAwsPollyS3Bucket header is set. The header is used only when this option is not set, and neither is used when pojoRequest is true.

String

s3KeyPrefix (producer)

The prefix of the Amazon S3 key of the output file of startSpeechSynthesisTask, to which Amazon Polly adds the task ID and the file extension: the output URI of the returned task gives the full location. The CamelAwsPollyS3KeyPrefix header is used only when this option is not set, and neither is used when pojoRequest is true.

String

sampleRate (producer)

The sample rate of the audio in Hz, as a string, for synthesizeSpeech and startSpeechSynthesisTask: 8000, 16000, 22050 or 24000 for mp3 and ogg_vorbis (also 44100 and 48000 for synthesizeSpeech), 8000 or 16000 for pcm, 48000 for ogg_opus and 8000 for mulaw and alaw. If not set, Amazon Polly uses 22050 for the standard engine and 24000 for the other engines with mp3 and ogg_vorbis, and 16000 with pcm. The CamelAwsPollySampleRate header is used only when this option is not set, and neither is used when pojoRequest is true.

String

snsTopicArn (producer)

The ARN of the Amazon SNS topic to which Amazon Polly sends the status notifications of a task of startSpeechSynthesisTask. If not set, no notification is sent. The CamelAwsPollySnsTopicArn header is used only when this option is not set, and neither is used when pojoRequest is true.

String

taskId (producer)

The ID of the speech synthesis task to get with getSpeechSynthesisTask, which fails when neither this option nor the CamelAwsPollyTaskId header is set. startSpeechSynthesisTask sets that header, but this option, when set, is used instead of it. Amazon Polly keeps a task for 72 hours. It is not used when pojoRequest is true.

String

textType (producer)

Whether the text of the body is plain text (text) or SSML (ssml), for synthesizeSpeech and startSpeechSynthesisTask. SSML must be valid, well-formed SSML in a speak element. When neither this option nor the CamelAwsPollyTextType header is set, text is used. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • ssml

  • text

  • null

TextType

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

voiceId (producer)

The ID of the voice that speaks the text, such as Joanna or Matthew, for synthesizeSpeech and startSpeechSynthesisTask, which fail when neither this option nor the CamelAwsPollyVoiceId header is set. The voice must support the engine of the request: describeVoices lists the voices and their engines. The header is used only when this option is not set, and neither is used when pojoRequest is true.

Enum values:

  • Aditi

  • Amy

  • Astrid

  • Bianca

  • Brian

  • Camila

  • Carla

  • Carmen

  • Celine

  • Chantal

  • Conchita

  • Cristiano

  • Dora

  • Emma

  • Enrique

  • Ewa

  • Filiz

  • Gabrielle

  • Geraint

  • Giorgio

  • Gwyneth

  • Hans

  • Ines

  • Ivy

  • Jacek

  • Jan

  • Joanna

  • Joey

  • Justin

  • Karl

  • Kendra

  • Kevin

  • Kimberly

  • Lea

  • Liv

  • Lotte

  • Lucia

  • Lupe

  • Mads

  • Maja

  • Marlene

  • Mathieu

  • Matthew

  • Maxim

  • Mia

  • Miguel

  • Mizuki

  • Naja

  • Nicole

  • Olivia

  • Penelope

  • Raveena

  • Ricardo

  • Ruben

  • Russell

  • Salli

  • Seoyeon

  • Takumi

  • Tatyana

  • Vicki

  • Vitoria

  • Zeina

  • Zhiyu

  • Aria

  • Ayanda

  • Arlet

  • Hannah

  • Arthur

  • Daniel

  • Liam

  • Pedro

  • Kajal

  • Hiujin

  • Laura

  • Elin

  • Ida

  • Suvi

  • Ola

  • Hala

  • Andres

  • Sergio

  • Remi

  • Adriano

  • Thiago

  • Ruth

  • Stephen

  • Kazuha

  • Tomoko

  • Niamh

  • Sofie

  • Lisa

  • Isabelle

  • Zayd

  • Danielle

  • Gregory

  • Burcu

  • Jitka

  • Sabrina

  • Jasmine

  • Jihye

  • Ambre

  • Beatrice

  • Florian

  • Lennart

  • Lorenzo

  • Tiffany

  • Arjun

  • Carlos

  • Carolina

  • Curtis

  • Hyunduk

  • Kenneth

  • Kiara

  • Leo

  • Nate

  • Tina

  • null

VoiceId

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

pollyClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.polly.PollyClient, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. The endpoint does not close a client that is set or autowired.

PollyClient

proxyHost (proxy)

The host name of the proxy that the HTTP client of Amazon Polly connects through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP client of Amazon Polly connects through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP client of Amazon Polly uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless pollyClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

profileCredentialsName (security)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless pollyClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails.

String

trustAllCertificates (security)

Whether the HTTP client of Amazon Polly trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

useDefaultCredentialsProvider (security)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (security)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Message Headers

The AWS Polly component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelAwsPollyOperation (producer)

Constant: OPERATION

The operation to perform. It replaces the operation option.

String

CamelAwsPollyVoiceId (producer)

Constant: VOICE_ID

The ID of the voice that speaks the text, such as Joanna, for synthesizeSpeech and startSpeechSynthesisTask. It is used only when the voiceId option is not set.

Enum values:

  • Aditi

  • Amy

  • Astrid

  • Bianca

  • Brian

  • Camila

  • Carla

  • Carmen

  • Celine

  • Chantal

  • Conchita

  • Cristiano

  • Dora

  • Emma

  • Enrique

  • Ewa

  • Filiz

  • Gabrielle

  • Geraint

  • Giorgio

  • Gwyneth

  • Hans

  • Ines

  • Ivy

  • Jacek

  • Jan

  • Joanna

  • Joey

  • Justin

  • Karl

  • Kendra

  • Kevin

  • Kimberly

  • Lea

  • Liv

  • Lotte

  • Lucia

  • Lupe

  • Mads

  • Maja

  • Marlene

  • Mathieu

  • Matthew

  • Maxim

  • Mia

  • Miguel

  • Mizuki

  • Naja

  • Nicole

  • Olivia

  • Penelope

  • Raveena

  • Ricardo

  • Ruben

  • Russell

  • Salli

  • Seoyeon

  • Takumi

  • Tatyana

  • Vicki

  • Vitoria

  • Zeina

  • Zhiyu

  • Aria

  • Ayanda

  • Arlet

  • Hannah

  • Arthur

  • Daniel

  • Liam

  • Pedro

  • Kajal

  • Hiujin

  • Laura

  • Elin

  • Ida

  • Suvi

  • Ola

  • Hala

  • Andres

  • Sergio

  • Remi

  • Adriano

  • Thiago

  • Ruth

  • Stephen

  • Kazuha

  • Tomoko

  • Niamh

  • Sofie

  • Lisa

  • Isabelle

  • Zayd

  • Danielle

  • Gregory

  • Burcu

  • Jitka

  • Sabrina

  • Jasmine

  • Jihye

  • Ambre

  • Beatrice

  • Florian

  • Lennart

  • Lorenzo

  • Tiffany

  • Arjun

  • Carlos

  • Carolina

  • Curtis

  • Hyunduk

  • Kenneth

  • Kiara

  • Leo

  • Nate

  • Tina

  • null

VoiceId

CamelAwsPollyOutputFormat (producer)

Constant: OUTPUT_FORMAT

The output format of synthesizeSpeech and startSpeechSynthesisTask: mp3, ogg_vorbis, ogg_opus, pcm, mulaw, alaw, or json for speech marks. It is used only when the outputFormat option is not set; when neither is set, mp3 is used.

Enum values:

  • json

  • mp3

  • ogg_opus

  • ogg_vorbis

  • pcm

  • mulaw

  • alaw

  • null

OutputFormat

CamelAwsPollyTextType (producer)

Constant: TEXT_TYPE

Whether the text of the body is plain text (text) or SSML (ssml), for synthesizeSpeech and startSpeechSynthesisTask. It is used only when the textType option is not set; when neither is set, text is used.

Enum values:

  • ssml

  • text

  • null

TextType

CamelAwsPollySampleRate (producer)

Constant: SAMPLE_RATE

The sample rate of the audio in Hz, such as 16000, for synthesizeSpeech and startSpeechSynthesisTask. It is used only when the sampleRate option is not set.

String

CamelAwsPollyEngine (producer)

Constant: ENGINE

The engine: standard, neural, long-form or generative. It is the engine of synthesizeSpeech and startSpeechSynthesisTask, and the filter of describeVoices. It is used only when the engine option is not set.

Enum values:

  • standard

  • neural

  • long-form

  • generative

  • null

Engine

CamelAwsPollyLanguageCode (producer)

Constant: LANGUAGE_CODE

A language code such as en-US: the language of a bilingual voice for synthesizeSpeech and startSpeechSynthesisTask, and the filter of describeVoices. It is used only when the languageCode option is not set.

String

CamelAwsPollyLexiconNames (producer)

Constant: LEXICON_NAMES

A comma-separated list of up to 5 names of pronunciation lexicons to apply during synthesizeSpeech and startSpeechSynthesisTask. It is used only when the lexiconNames option is not set.

String

CamelAwsPollyLexiconName (producer)

Constant: LEXICON_NAME

The name of the pronunciation lexicon for getLexicon, putLexicon and deleteLexicon. It is used only when the lexiconName option is not set.

String

CamelAwsPollyLexiconContent (producer)

Constant: LEXICON_CONTENT

The pronunciation lexicon that putLexicon stores, as a PLS XML document. It is used only when the lexiconContent option is not set; when neither is set, the body is used.

String

CamelAwsPollyTaskId (producer)

Constant: TASK_ID

The ID of a speech synthesis task. startSpeechSynthesisTask sets it to the ID of the task it started, and getSpeechSynthesisTask reads it when the taskId option is not set.

String

CamelAwsPollyS3Bucket (producer)

Constant: S3_BUCKET

The name of the Amazon S3 bucket in which startSpeechSynthesisTask stores the output file. It is used only when the s3Bucket option is not set.

String

CamelAwsPollyS3KeyPrefix (producer)

Constant: S3_KEY_PREFIX

The prefix of the Amazon S3 key of the output file of startSpeechSynthesisTask. It is used only when the s3KeyPrefix option is not set.

String

CamelAwsPollySnsTopicArn (producer)

Constant: SNS_TOPIC_ARN

The ARN of the Amazon SNS topic for the status notifications of a task of startSpeechSynthesisTask. It is used only when the snsTopicArn option is not set.

String

CamelAwsPollyContentType (producer)

Constant: CONTENT_TYPE

The content type of the output that synthesizeSpeech returns, such as audio/mpeg for mp3, audio/ogg for ogg_vorbis and ogg_opus, audio/pcm for pcm, or application/x-json-stream for speech marks.

String

CamelAwsPollyRequestCharacters (producer)

Constant: REQUEST_CHARACTERS

The number of characters that Amazon Polly synthesized for synthesizeSpeech.

Integer

CamelAwsPollyNextToken (producer)

Constant: NEXT_TOKEN

The token of the next page for the describeVoices, listLexicons and listSpeechSynthesisTasks operations. It is in and out: when set, it is sent as the next token of the request, and after the call it holds the next token of the response, or it is removed when the response has none, which is the last page. Remove it before calling a different list operation.

String

Message Body

The message body at each side of the AWS Polly component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

any

The text to speak for synthesizeSpeech, the default, and startSpeechSynthesisTask: plain text, or SSML with textType=ssml. Bytes, a stream or a file are read as text, a Map or a POJO is spoken as its toString(), so take the text out of it first, and no body fails. putLexicon takes the lexicon from the body when neither the lexiconContent option nor the CamelAwsPollyLexiconContent header is set. The other operations do not use the body. With pojoRequest=true the request of the AWS SDK for the operation, such as a SynthesizeSpeechRequest: another body fails.

  • With operation=synthesizeSpeech: text, bytes, stream or file

  • With operation=startSpeechSynthesisTask: text, bytes, stream or file

Producer output

pojo

The audio of synthesizeSpeech, the default, as a stream, with its content type and the number of characters in headers: read it once, or write it to a file. A List for describeVoices, listLexicons and listSpeechSynthesisTasks, the SynthesisTask for startSpeechSynthesisTask, with its id in a header, and getSpeechSynthesisTask, the Lexicon for getLexicon, and the response of the AWS SDK for putLexicon and deleteLexicon.

  • With operation=synthesizeSpeech: stream

  • With operation=describeVoices: list (java.util.List<software.amazon.awssdk.services.polly.model.Voice>)

  • With operation=listLexicons: list (java.util.List<software.amazon.awssdk.services.polly.model.LexiconDescription>)

  • With operation=listSpeechSynthesisTasks: list (java.util.List<software.amazon.awssdk.services.polly.model.SynthesisTask>)

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Required Polly component options

You have to provide the pollyClient in the Registry or your accessKey and secretKey to access the Amazon Polly service.

Usage

Static credentials, Default Credential Provider and Profile Credentials Provider

You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.

The order of evaluation for Default Credentials Provider is the following:

  • Java system properties - aws.accessKeyId and aws.secretKey

  • Environment variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

  • Web Identity Token from AWS STS.

  • The shared credentials and config files.

  • Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is set.

  • Amazon EC2 Instance profile credentials.

You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.

Only one of static, default and profile credentials could be used at the same time.

For more information about this you can look at AWS credentials documentation

Polly Producer operations

Camel-AWS Polly component provides the following operations on the producer side:

  • synthesizeSpeech

  • describeVoices

  • listLexicons

  • getLexicon

  • putLexicon

  • deleteLexicon

  • startSpeechSynthesisTask

  • getSpeechSynthesisTask

  • listSpeechSynthesisTasks

Text type and output format

The textType option, or else the CamelAwsPollyTextType header, says whether the text is plain text (TEXT) or SSML (SSML). The outputFormat option, or else the CamelAwsPollyOutputFormat header, sets the audio format. When neither the option nor the header is set, TEXT and MP3 are used. This applies to the synthesizeSpeech and startSpeechSynthesisTask operations.

The lexiconNames option, or else the CamelAwsPollyLexiconNames header, is a comma-separated list of lexicon names. The spaces around each name are removed, so a, b is the same as a,b.

Paging the list operations

The describeVoices, listLexicons and listSpeechSynthesisTasks operations return one page of results in the body. The CamelAwsPollyNextToken header is both an input and an output:

  • when it is set, it is sent as the next token of the request, so the call returns the next page;

  • after the call, it holds the next token of the response, or it is removed when the response has none, which means this was the last page.

A route can therefore call the operation again while the header is set. Because the header stays on the message, remove it before calling a different list operation, or that call starts from a token that is not its own.

  • Java

  • YAML

from("direct:start")
  .to("aws2-polly://test?operation=listLexicons")
  .log("Lexicons: ${body}")
  .loopDoWhile(header(Polly2Constants.NEXT_TOKEN).isNotNull())
    .to("aws2-polly://test?operation=listLexicons")
    .log("Lexicons: ${body}")
  .end()
  .removeHeader(Polly2Constants.NEXT_TOKEN)
  .to("aws2-polly://test?operation=describeVoices");
- route:
    from:
      uri: direct:start
      steps:
        - to:
            uri: aws2-polly:test
            parameters:
              operation: listLexicons
        - log:
            message: "Lexicons: ${body}"
        - loop:
            doWhile: true
            expression:
              simple:
                expression: "${header.CamelAwsPollyNextToken} != null"
            steps:
              - to:
                  uri: aws2-polly:test
                  parameters:
                    operation: listLexicons
              - log:
                  message: "Lexicons: ${body}"
        - removeHeader:
            name: CamelAwsPollyNextToken
        - to:
            uri: aws2-polly:test
            parameters:
              operation: describeVoices

With pojoRequest=true, the next token is taken from the request in the body, and the CamelAwsPollyNextToken header is set from the response in the same way.

Examples

Synthesize Speech example

Java-only: uses AWS SDK enum constants for header values
from("direct:start")
  .setHeader(Polly2Constants.VOICE_ID, constant(VoiceId.JOANNA))
  .setBody(constant("Hello, this is a test of Amazon Polly text to speech synthesis."))
  .to("aws2-polly://test?operation=synthesizeSpeech")
  .to("file:output?fileName=speech.mp3");

As a result, you’ll get an exchange containing the audio stream (InputStream) with the synthesized speech.

Using Neural Voices

Java-only: uses AWS SDK enum constants for header values
from("direct:start")
  .setHeader(Polly2Constants.VOICE_ID, constant(VoiceId.MATTHEW))
  .setHeader(Polly2Constants.ENGINE, constant(Engine.NEURAL))
  .setBody(constant("This is synthesized using a neural voice."))
  .to("aws2-polly://test?operation=synthesizeSpeech&outputFormat=MP3");

Describe Voices example

  • Java

  • XML

  • YAML

from("direct:start")
  .to("aws2-polly://test?operation=describeVoices")
  .log("Available voices: ${body}");
<route>
  <from uri="direct:start"/>
  <to uri="aws2-polly://test?operation=describeVoices"/>
  <log message="Available voices: ${body}"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - to:
            uri: aws2-polly://test
            parameters:
              operation: describeVoices
        - log:
            message: "Available voices: ${body}"

Asynchronous Speech Synthesis with S3

For long text, you can use asynchronous synthesis which stores the result in S3:

Java-only: uses Java constants for header names
from("direct:start")
  .setHeader(Polly2Constants.VOICE_ID, constant(VoiceId.JOANNA))
  .setHeader(Polly2Constants.S3_BUCKET, constant("my-audio-bucket"))
  .setHeader(Polly2Constants.S3_KEY_PREFIX, constant("audio/"))
  .setBody(constant("This is a very long text that will be synthesized asynchronously..."))
  .to("aws2-polly://test?operation=startSpeechSynthesisTask");

Using a POJO as body

Sometimes building an AWS Request can be complex because of multiple options. We introduce the possibility to use a POJO as the body. In AWS Polly, you can do something like:

Java-only: uses AWS SDK request builder API
from("direct:start")
  .setBody(SynthesizeSpeechRequest.builder()
              .voiceId(VoiceId.JOANNA)
              .outputFormat(OutputFormat.MP3)
              .text("Hello from Camel!")
              .build())
  .to("aws2-polly://test?operation=synthesizeSpeech&pojoRequest=true");

In this way, you’ll pass the request directly without the need of passing headers and options specifically related to this operation.

Dependencies

Maven users will need to add the following dependency to their pom.xml.

pom.xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-aws2-polly</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel.