Skip to main content

Deepgram 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

ParameterTypeDefaultDescription
api_keystrRequiredYour Deepgram API key.
base_urlstr""Custom Deepgram API base URL.
sample_rateintNoneAudio sample rate. Defaults to transport rate.
live_optionsLiveOptionsNoneDeepgram-specific transcription options.

Default LiveOptions

If no live_options are provided, Piopiy uses these defaults:

OptionDefault
model"nova-3-general"
language"en"
interim_resultsTrue
smart_formatTrue
punctuateTrue

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-3 is the latest and fastest model for general use cases.
  • Interim Results: Enabled by default to provide the LLM with early context, reducing perceived latency.