start_speech_synthesis_stream¶
Operation¶
Async only
This operation uses an event stream, so only the asynchronous client supports it.
start_speech_synthesis_stream
async
¶
start_speech_synthesis_stream(request: StartSpeechSynthesisStreamInput | StartSpeechSynthesisStreamInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[StartSpeechSynthesisStreamInputDict]) -> AsyncDuplexEventStream[StartSpeechSynthesisStreamActionStream, StartSpeechSynthesisStreamEventStream, StartSpeechSynthesisStreamOutput]
Synthesizes UTF-8 input, plain text, or SSML over a bidirectional streaming connection. Specify synthesis parameters in HTTP/2 headers, send text incrementally as events on the input stream, and receive synthesized audio as it becomes available.
This operation serves as a bidirectional counterpart to
SynthesizeSpeech:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
StartSpeechSynthesisStreamInput | StartSpeechSynthesisStreamInputDict | None
|
The input as a model or dictionary. Pass this or keyword arguments, not both. |
None
|
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
**kwargs
|
Unpack[StartSpeechSynthesisStreamInputDict]
|
The input fields as keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
AsyncDuplexEventStream[StartSpeechSynthesisStreamActionStream, StartSpeechSynthesisStreamEventStream, StartSpeechSynthesisStreamOutput]
|
An |
Input¶
Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.
StartSpeechSynthesisStreamInputDict
¶
Bases: TypedDict
Dictionary form of StartSpeechSynthesisStreamInput.
Attributes¶
engine
instance-attribute
¶
Specifies the engine for Amazon Polly to use when processing input text
for speech synthesis. Currently, only the generative engine is
supported. If you specify a voice that the selected engine doesn't
support, Amazon Polly returns an error.
language_code
instance-attribute
¶
language_code: str | None
An optional parameter that sets the language code for the speech synthesis request. Specify this parameter only when using a bilingual voice. If a bilingual voice is used and no language code is specified, Amazon Polly uses the default language of the bilingual voice.
lexicon_names
instance-attribute
¶
The names of one or more pronunciation lexicons for the service to apply during synthesis. Amazon Polly applies lexicons only when the lexicon language matches the voice language.
output_format
instance-attribute
¶
The audio format for the synthesized speech. Currently, Amazon Polly does not support JSON speech marks.
voice_id
instance-attribute
¶
The voice to use in synthesis. To get a list of available voice IDs, use the DescribeVoices operation.
StartSpeechSynthesisStreamInput
dataclass
¶
Bases: _SerdeShape
Dataclass for StartSpeechSynthesisStreamInput structure.
Attributes¶
engine
class-attribute
instance-attribute
¶
engine: str | None = ...
Specifies the engine for Amazon Polly to use when processing input text
for speech synthesis. Currently, only the generative engine is
supported. If you specify a voice that the selected engine doesn't
support, Amazon Polly returns an error.
language_code
class-attribute
instance-attribute
¶
language_code: str | None = ...
An optional parameter that sets the language code for the speech synthesis request. Specify this parameter only when using a bilingual voice. If a bilingual voice is used and no language code is specified, Amazon Polly uses the default language of the bilingual voice.
lexicon_names
class-attribute
instance-attribute
¶
The names of one or more pronunciation lexicons for the service to apply during synthesis. Amazon Polly applies lexicons only when the lexicon language matches the voice language.
output_format
class-attribute
instance-attribute
¶
output_format: str | None = ...
The audio format for the synthesized speech. Currently, Amazon Polly does not support JSON speech marks.
sample_rate
class-attribute
instance-attribute
¶
sample_rate: str | None = ...
The audio frequency, specified in Hz.
voice_id
class-attribute
instance-attribute
¶
voice_id: str | None = ...
The voice to use in synthesis. To get a list of available voice IDs, use the DescribeVoices operation.
Output¶
This operation returns an AsyncDuplexEventStream for bidirectional streaming.
Event Stream Structure¶
Input Event Type¶
StartSpeechSynthesisStreamActionStream
Output Event Type¶
StartSpeechSynthesisStreamEventStream
Initial Response Structure¶
StartSpeechSynthesisStreamOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for StartSpeechSynthesisStreamOutput structure.