Soniox
The SonioxSTTService offers real-time speech-to-text with a focus on high precision and structured output. It supports speaker diarization and custom context for domain-specific vocabulary.
Installation
To use Soniox, install the required dependencies:
pip install "piopiy-ai[soniox]"
Prerequisites
- A Soniox account and API key (Get yours here).
- Set your API key in your environment:
export SONIOX_API_KEY="your_api_key_here"
Configuration
SonioxSTTService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Soniox API key. |
sample_rate | int | None | Audio sample rate in Hz. |
params | SonioxInputParams | None | Model and diarization settings. |
SonioxInputParams
| Parameter | Type | Default | Description |
|---|---|---|---|
model | str | "stt-rt-preview" | Model ID for transcription. |
language_hints | List[Language] | None | Hints to guide language detection. |
context | SonioxContextObject | None | Custom vocabulary or phrases. |
enable_speaker_diarization | bool | False | Enable speaker identification. |
Usage
Basic Setup
import os
from piopiy.services.soniox.stt import SonioxSTTService, SonioxInputParams
stt = SonioxSTTService(
api_key=os.getenv("SONIOX_API_KEY"),
params=SonioxInputParams(
model="stt-rt-preview",
enable_speaker_diarization=True
)
)
Notes
- Contextual Accuracy: Use the
contextparameter to provide specific terms (e.g., product names, technical jargon) to improve transcription accuracy in specialized domains. - Diarization: Soniox provides per-token speaker identification, allowing for precise attribution of speech in multi-party conversations.