Deepgram STT
The DeepgramSTTService provides high-performance, low-latency speech recognition using Deepgram's WebSocket API. It's the recommended STT provider for most production real-time voice applications.
Installation
To use Deepgram, install the required dependencies:
pip install "piopiy-ai[deepgram]"
Prerequisites
- A Deepgram account and API key (Get yours here).
- Set your API key in your environment:
export DEEPGRAM_API_KEY="your_api_key_here"
Configuration
DeepgramSTTService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Deepgram API key. |
base_url | str | "" | Custom Deepgram API base URL. |
sample_rate | int | None | Audio sample rate. Defaults to transport rate. |
live_options | LiveOptions | None | Deepgram-specific transcription options. |
Default LiveOptions
If no live_options are provided, Piopiy uses these defaults:
| Option | Default |
|---|---|
model | "nova-3-general" |
language | "en" |
interim_results | True |
smart_format | True |
punctuate | True |
Usage
Basic Setup
import os
from piopiy.services.deepgram.stt import DeepgramSTTService
stt = DeepgramSTTService(
api_key=os.getenv("DEEPGRAM_API_KEY"),
)
With Custom LiveOptions
from deepgram import LiveOptions
from piopiy.services.deepgram.stt import DeepgramSTTService
options = LiveOptions(
model="nova-2-medical",
language="en-US",
smart_format=True
)
stt = DeepgramSTTService(
api_key=os.getenv("DEEPGRAM_API_KEY"),
live_options=options
)
Notes
- Model Selection:
nova-3is the latest and fastest model for general use cases. - Interim Results: Enabled by default to provide the LLM with early context, reducing perceived latency.