Skip to content

PollyClient.start_speech_synthesis_stream

rboto-polly==0.4.0 · Service index · Types

Model summary (excerpt): 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 : SynthesizeSpeech To use a custom voice, specify its ID in VoiceId . The...

Install and imports

python -m pip install "rboto[polly]==0.4.0"
from rboto import PollyClient
from collections.abc import AsyncIterator, Sequence
from rboto_polly.types import (
    Engine,
    LanguageCode,
    OutputFormat,
    StartSpeechSynthesisStreamActionStream,
    StartSpeechSynthesisStreamOutput,
    VoiceId,
)

Signature

async def start_speech_synthesis_stream(
    *,
    engine: Engine,
    output_format: OutputFormat,
    voice_id: VoiceId,
    language_code: LanguageCode | None = None,
    lexicon_names: Sequence[str] | None = None,
    sample_rate: str | None = None,
    action_stream: AsyncIterator[StartSpeechSynthesisStreamActionStream] | None = None,
) -> StartSpeechSynthesisStreamOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
engine Yes 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.
output_format Yes The audio format for the synthesized speech. Currently, Amazon Polly does not support JSON speech marks.
voice_id Yes The voice ID to use for the synthesis. To get a list of available voice IDs, use the DescribeVoices operation. To use a custom voice, specify the voice ID that CreateVoice returned, for example, vc-9a8fa85dd3 . You can't specify the ARN of a voice.
language_code No 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 No 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.
sample_rate No The audio frequency, specified in Hz.
action_stream No The input event stream that contains text events and stream control events.

Output

StartSpeechSynthesisStreamOutput.

Typed response mapping, accessed as response["field"].

Field Type Presence References
event_stream AsyncIterator[StartSpeechSynthesisStreamEventStream] Always present StartSpeechSynthesisStreamEventStream

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

Engine, LanguageCode, OutputFormat, StartSpeechSynthesisStreamActionStream, StartSpeechSynthesisStreamOutput, VoiceId

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

Output streams: StartSpeechSynthesisStreamOutput.

Consume with async for. Do not reuse a consumed stream.

Input event streams accept the declared AsyncIterator of typed events.

Errors

Import from rboto_polly.exceptions:

ConflictError, ResourceNotFoundError, ServiceFailureError, ServiceQuotaExceededError, ThrottlingError, ValidationError.

Stream decoding may also raise the linked modeled event errors.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model