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.0.0.tar.gz (34.6 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.0.0-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: amazon_polly_streaming-1.0.0.tar.gz
  • Upload date:
  • Size: 34.6 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.0.0.tar.gz
Algorithm Hash digest
SHA256 540b8bec24a05899231efe83bd02be412b1ce9035762f0a3c8ef1486a01bc3fa
MD5 7979597f1c584a7b45ee320f61b5c30f
BLAKE2b-256 60e1dadfec2c58f294a698415b4582dd313d5e9baa340251f1c16ec883e7ae53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for amazon_polly_streaming-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96a65e5c3a68b33335e4c2c10a550f4132a2ac2017640813282d1c66bc57b8bf
MD5 64696a471c650092e42c41789ac29ca0
BLAKE2b-256 441ea604f8344174d204034a098b130c4adda4b27e1938131296f4fd3d001a3b

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