Skip to main content

Amazon Polly bidirectional streaming over HTTP/2 with SigV4 (the API boto3 does not yet expose)

Project description

Amazon Polly bidirectional streaming over HTTP/2 with SigV4: implements StartSpeechSynthesisStream, the Polly API that boto3 does not yet expose (only the AWS Java SDK has it).

  • Async generator interface: async for chunk in client.start_speech_synthesis_stream(...) yields audio bytes as they arrive from Polly, with no need to wait for the full audio to be generated server-side.

  • Real bidirectional: events sent to Polly and audio events received are framed in AWS event-stream over HTTP/2, with rolling chunk-signatures (the same scheme amazon-transcribe-streaming-sdk uses for Transcribe streaming).

  • Typed: PEP 561 py.typed marker; full pyright-strict surface for downstream consumers.

Full documentation on readthedocs.

Installation

pip install amazon-polly-streaming

Quick start

import asyncio
from amazon_polly_streaming import PollyStreamingClient

async def main() -> None:
    client = PollyStreamingClient(region="eu-central-1")
    audio = b""
    async for chunk in client.start_speech_synthesis_stream(
        text="hello world, how are you today",
        voice_id="Matthew",
        engine="generative",
        language_code="en-US",
        output_format="mp3",
        sample_rate="24000",
    ):
        audio += chunk
    with open("hello.mp3", "wb") as fh:
        fh.write(audio)

asyncio.run(main())

The voice_id must be a generative voice supporting bidirectional streaming. See the Amazon Polly Generative voices page for the current list and supported regions.

Requirements

  • Python 3.13+

  • AWS credentials in the default chain (env vars, profile, or IAM role) with polly:StartSpeechSynthesisStream permission

  • A region supporting Polly bidirectional streaming (us-east-1, us-west-2, eu-central-1, eu-west-2, ap-southeast-1, ca-central-1 as of 2026-05)

License

This package is released under the Apache License 2.0. See LICENSE and NOTICE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amazon_polly_streaming-1.1.0.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amazon_polly_streaming-1.1.0-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file amazon_polly_streaming-1.1.0.tar.gz.

File metadata

  • Download URL: amazon_polly_streaming-1.1.0.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for amazon_polly_streaming-1.1.0.tar.gz
Algorithm Hash digest
SHA256 48640089be3090304eb114232d09c10e3eff106372c54a3e240357c288dadb2a
MD5 287ce9950f8ab331d8db5ae09db10b4c
BLAKE2b-256 7bcdf7678d91a19fa64473bd92533b8f632d58a62d689df7ef82647ab9afda66

See more details on using hashes here.

File details

Details for the file amazon_polly_streaming-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for amazon_polly_streaming-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fd41b0e2920398ed48c23bbf0307d781447aa90c88fae71e8c49f27b5c963ed
MD5 f775c2feacc614d5db1d3ee2db286ca3
BLAKE2b-256 c71fa2479765b9062256f4053e32ad5418a345e214c9ab9e82c803ae45ac303d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page