Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Deepgram Python SDK Examples

This directory contains comprehensive examples demonstrating how to use the Deepgram Python SDK. Examples are organized by feature area, with each section starting at a multiple of 10.

Examples Overview

01-09: Authentication

  • 01-authentication-api-key.py - API key authentication
  • 02-authentication-access-token.py - Access token authentication

10-19: Transcription (Listen)

  • 10-transcription-prerecorded-url.py - Transcribe audio from URL
  • 11-transcription-prerecorded-file.py - Transcribe audio from local file
  • 12-transcription-prerecorded-callback.py - Async transcription with callbacks
  • 13-transcription-live-websocket.py - Live transcription via WebSocket (Listen V1)
  • 14-transcription-live-websocket-v2.py - Live transcription via WebSocket (Listen V2)
  • 15-transcription-advanced-options.py - Advanced transcription options

20-29: Text-to-Speech (Speak)

  • 20-text-to-speech-single.py - Single request TTS (REST API)
  • 21-text-to-speech-streaming.py - Streaming TTS via WebSocket
  • 22-text-builder-demo.py - TextBuilder demo (no API key required)
  • 23-text-builder-helper.py - TextBuilder with REST API generation
  • 24-text-builder-streaming.py - TextBuilder with streaming TTS (WebSocket)

30-39: Voice Agent

  • 30-voice-agent.py - Voice Agent configuration and usage

40-49: Text Intelligence (Read)

  • 40-text-intelligence.py - Text analysis using AI features

50-59: Management API

  • 50-management-projects.py - Project management (list, get, update, delete)
  • 51-management-keys.py - API key management (list, get, create, delete)
  • 52-management-members.py - Member management (list, remove, scopes)
  • 53-management-invites.py - Invitation management (list, send, delete, leave)
  • 54-management-usage.py - Usage statistics and request information
  • 55-management-billing.py - Billing and balance information
  • 56-management-models.py - Model information

60-69: On-Premises

  • 60-onprem-credentials.py - On-premises credentials management

70-79: Configuration & Advanced

  • 70-request-options.py - Request options including additional query parameters
  • 71-error-handling.py - Error handling patterns

Usage

  1. Install dependencies:
pip install -r requirements.txt
  1. Set your API key as an environment variable:
export DEEPGRAM_API_KEY="your-api-key-here"

Or create a .env file:

DEEPGRAM_API_KEY=your-api-key-here
  1. Run an example:
python examples/01-authentication-api-key.py

Getting an API Key

🔑 To access the Deepgram API you will need a free Deepgram API Key.

Documentation

For more information, see:

Notes

  • All examples use production-ready patterns, not testing patterns
  • Examples demonstrate both synchronous and async usage (see comments in each file)
  • Replace placeholder values (API keys, project IDs, etc.) with actual values
  • Some examples require specific file paths or URLs - adjust as needed for your environment
  • Each example includes comments showing variations (async, access tokens, etc.)