Skip to main content

Soniox 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

ParameterTypeDefaultDescription
api_keystrRequiredYour Soniox API key.
sample_rateintNoneAudio sample rate in Hz.
paramsSonioxInputParamsNoneModel and diarization settings.

SonioxInputParams

ParameterTypeDefaultDescription
modelstr"stt-rt-preview"Model ID for transcription.
language_hintsList[Language]NoneHints to guide language detection.
contextSonioxContextObjectNoneCustom vocabulary or phrases.
enable_speaker_diarizationboolFalseEnable 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 context parameter 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.