Azure STT
The AzureSTTService leverages Microsoft Azure's Cognitive Services Speech SDK for high-quality, real-time audio transcription. It is suitable for applications requiring broad language support and deep integration with the Azure ecosystem.
Installation
To use Azure STT, install the required dependencies:
pip install "piopiy-ai[azure]"
Prerequisites
- An Azure subscription and a Speech service resource (Get yours here).
- Azure API key and region (e.g.,
eastus). - Set your credentials in your environment:
export AZURE_SPEECH_API_KEY="your_api_key_here"
export AZURE_SPEECH_REGION="your_region_here"
Configuration
AzureSTTService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Azure Speech subscription key. |
region | str | Required | Azure region (e.g., "eastus"). |
language | Language | EN_US | Language for speech recognition. |
sample_rate | int | None | Audio sample rate in Hz. |
endpoint_id | str | None | Custom model endpoint ID (if using Custom Speech). |
Usage
Basic Setup
import os
from piopiy.services.azure.stt import AzureSTTService
from piopiy.transcriptions.language import Language
stt = AzureSTTService(
api_key=os.getenv("AZURE_SPEECH_API_KEY"),
region=os.getenv("AZURE_SPEECH_REGION"),
language=Language.EN_US
)
Notes
- Continuous Recognition: The service uses Azure's continuous recognition mode, providing both interim and final results as the user speaks.
- Custom Models: If you have trained a custom speech model in Azure Speech Studio, you can provide the
endpoint_idto use it.