Skip to main content

AWS AWS Transcribe

The AWSTranscribeSTTService provides real-time speech-to-text using AWS Transcribe's streaming WebSocket API. It is a robust choice for developers already using the AWS infrastructure.

Installation

To use AWS Transcribe, install the required dependencies:

pip install "piopiy-ai[aws]"

Prerequisites

  • An AWS account with permissions for transcribe:StartStreamTranscription (Get yours here).
  • AWS Access Key, Secret Key, and Region.
  • Configure your environment or AWS credentials file:
    export AWS_ACCESS_KEY_ID="your_access_key"
    export AWS_SECRET_ACCESS_KEY="your_secret_key"
    export AWS_REGION="us-east-1"

Configuration

AWSTranscribeSTTService Parameters

ParameterTypeDefaultDescription
aws_access_key_idstrNoneAWS Access Key ID (defaults to env var).
api_keystrNoneAWS Secret Access Key (defaults to env var).
regionstrNoneAWS Region (e.g., "us-east-1").
sample_rateint16000Sample rate (must be 8000 or 16000).
languageLanguageENLanguage for transcription.

Usage

Basic Setup

import os
from piopiy.services.aws.stt import AWSTranscribeSTTService
from piopiy.transcriptions.language import Language

stt = AWSTranscribeSTTService(
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
api_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
region="us-east-1",
language=Language.EN,
sample_rate=16000
)

Notes

  • Sample Rate: AWS Transcribe streaming only supports 8000 Hz or 16000 Hz. Piopiy will log a warning and default to 16000 Hz if an unsupported rate is provided.
  • WebSocket Protocol: This service uses the HTTP/2 or WebSocket protocol for efficient, low-latency streaming.