AWS SDK for Transcribe Streaming

raw JSON →
0.5.0 verified Fri May 01 auth: no python

The aws-sdk-transcribe-streaming library (v0.5.0) is an unofficial, community-maintained Python SDK for Amazon Transcribe's streaming API. It provides a high-level interface to start real-time transcription using WebSocket connections. Requires Python 3.12+. Release cadence is irregular.

pip install aws-sdk-transcribe-streaming
error ValueError: The language code 'en-GB' is not supported
cause Only specific language codes are supported; 'en-GB' is not listed in AWS Transcribe streaming documentation.
fix
Use a supported language code such as 'en-US', 'es-US', 'ja-JP', etc. See AWS docs for full list.
error AttributeError: module 'aws_sdk_transcribe_streaming' has no attribute 'TranscribeStreamingClient'
cause Importing from the wrong path or the library is not installed.
fix
Install the library: pip install aws-sdk-transcribe-streaming and use 'from aws_sdk_transcribe_streaming import TranscribeStreamingClient'.
breaking Breaking: The library dropped support for Python <3.12 in v0.5.0. Using with older Python versions will fail with a syntax error.
fix Upgrade Python to 3.12+ or pin to aws-sdk-transcribe-streaming<0.5.0.
gotcha The library uses asyncio under the hood. All client methods must be awaited; forgetting 'await' leads to coroutine objects instead of results.
fix Ensure all calls to client methods are prefixed with 'await' inside an async function.
deprecated Use of 'TranscribeStreamingClient' without explicit region may fail silently. In earlier versions region defaulted to 'us-east-1' but new releases require explicit parameter.
fix Pass 'region' explicitly when constructing the client.

Create a client and start a transcription stream.

import os
import asyncio
from aws_sdk_transcribe_streaming import TranscribeStreamingClient

async def transcribe():
    client = TranscribeStreamingClient(
        region="us-west-2",
        aws_access_key_id=os.environ.get("AWS_ACCESS_KEY_ID", ""),
        aws_secret_access_key=os.environ.get("AWS_SECRET_ACCESS_KEY", ""),
    )
    result = await client.start_stream_transcription(
        language_code="en-US",
        media_sample_rate_hz=16000,
        media_encoding="pcm",
    )
    print(result)

asyncio.run(transcribe())