Agent skill

Deepgram Python Text-to-Speech

by deepgram in deepgram/deepgram-python-sdk

Guides Python code that calls Deepgram Text-to-Speech v1, covering one-shot REST, streaming WebSocket and the TextBuilder helper.

MITAuto-check passedMedia & Creative

Install Deepgram Python Text-to-Speech

skills CLI
$ npx skills add deepgram/deepgram-python-sdk --skill deepgram-python-text-to-speech -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install deepgram/deepgram-python-sdk deepgram-python-text-to-speech --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/deepgram/deepgram-python-sdk.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/deepgram-python-text-to-speech .claude/skills/deepgram-python-text-to-speech && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
deepgram-python-text-to-speech
GitHub stars
469
Token cost
~1.8k tokens
SKILL.md length
492 words
Files
1
Skills in repo
7
Repo updated
First seen
Licence
MIT

At a glance

Guides Python code that calls Deepgram Text-to-Speech v1, covering one-shot REST, streaming WebSocket and the TextBuilder helper.

  • Works in 5 steps: In-repo reference: reference.md —… → OpenAPI (REST):… → AsyncAPI (WSS):… → …
  • Synthesizing speech from text with the Deepgram Python SDK
  • SKILL.md covers When to use this product, Authentication, Quick start — REST (one-shot) and Quick start — WebSocket…, plus 7 more sections
  • Calls npx; needs DEEPGRAM_API_KEY

What it does

Python code that calls Deepgram Text-to-Speech v1 at /v1/speak is covered along two paths. One-shot REST with client.speak.v1.audio.generate returns an iterator of audio bytes for rendered files or pre-generated prompts, and a streaming WebSocket with client.speak.v1.connect gives low-latency playback while an LLM is still producing tokens.

Authentication uses an Authorization header with the Token scheme rather than Bearer. In sync WebSocket mode, start_listening blocks, so text, flush and close are sent first or it runs in a thread; in async mode it runs as a task. The in-repo TextBuilder helper assembles English Flux batch text with pronunciation markers and pauses, where pauses run 500 to 3000 ms in 100 ms steps with at most eight per request and the two controls cannot be combined. Full-duplex voice agents belong to deepgram-python-voice-agent.

When your agent uses it

  • Synthesizing speech from text with the Deepgram Python SDK
  • Streaming audio over a WebSocket while an LLM is still generating
  • Adding pronunciation or pause controls to Flux batch text
  • Reviewing Python code that calls speak.v1

Example prompts

  • “Write a Python script that turns this paragraph into an MP3 with Deepgram text to speech.”
  • “Stream synthesized audio over a WebSocket as tokens arrive from the model.”
  • “Use TextBuilder to add a one-second pause between these two sentences.”

Requirements

  • A Deepgram API key
  • Python with the Deepgram SDK

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. In-repo reference: reference.md — sections "Speak V1 Audio" (REST) and "Speak V1 Connect" (WSS).
  2. OpenAPI (REST): https://developers.deepgram.com/openapi.yaml
  3. AsyncAPI (WSS): https://developers.deepgram.com/asyncapi.yaml
  4. Context7: library ID /llmstxt/developers_deepgram_llms_txt.
  5. Product docs

What it can do on your machine

Read from SKILL.md and the folder at commit 5c2f3af. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • developers.deepgram.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • DEEPGRAM_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Deepgram Python Text-to-Speech loads about 1.8k tokens when it runs. Until then it costs about 142 tokens; SKILL.md has 492 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~142
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from deepgram/deepgram-python-sdk at commit 5c2f3af, republished under its MIT licence (© deepgram). 492 words, ~1,805 tokens.

Download SKILL.mdSave it as .claude/skills/deepgram-python-text-to-speech/SKILL.md (or your agent's skills folder).
name
deepgram-python-text-to-speech
description
Use when writing or reviewing Python code in this repo that calls Deepgram Text-to-Speech v1 (`/v1/speak`) for audio synthesis. Covers one-shot REST (`client.speak.v1.audio.generate`) and streaming WebSocket (`client.speak.v1.connect`). Also covers the in-repo `deepgram.helpers.TextBuilder` for incremental text assembly before synthesis. Use `deepgram-python-voice-agent` when you need full-duplex STT + LLM + TTS with barge-in. Triggers include "TTS", "speak", "synthesize voice", "aura", "text to speech", "speak.v1", "TextBuilder".

Using Deepgram Text-to-Speech (Python SDK)

Convert text to audio: one-shot REST download or low-latency streaming synthesis via /v1/speak.

When to use this product

  • REST (speak.v1.audio.generate) — one-shot synthesis, returns audio bytes. Use for rendered files, pre-generated prompts, anything where you have the full text upfront.
  • WebSocket (speak.v1.connect) — incremental text input, streaming audio output. Use for low-latency playback while an LLM is still producing tokens.

Use a different skill when:

  • You need the agent to also listen and converse (full-duplex) → deepgram-python-voice-agent.

Authentication

python
from dotenv import load_dotenv
load_dotenv()

from deepgram import DeepgramClient
client = DeepgramClient()  # reads DEEPGRAM_API_KEY

Header: Authorization: Token <api_key> (NOT Bearer).

Quick start — REST (one-shot)

python
audio_iter = client.speak.v1.audio.generate(
    text="Hello, this is a text to speech example.",
    model="aura-2-asteria-en",
    encoding="linear16",
    sample_rate=24000,
)

with open("output.raw", "wb") as f:
    for chunk in audio_iter:
        f.write(chunk)

Returns an iterator of bytes (streaming audio response). The response body is audio/*, NOT JSON. Useful response headers: dg-model-name, dg-char-count, dg-request-id.

Quick start — WebSocket (streaming)

python
from deepgram.core.events import EventType
from deepgram.speak.v1.types import SpeakV1Text

with client.speak.v1.connect(
    model="aura-2-asteria-en",
    encoding="linear16",
    sample_rate=24000,
) as conn:
    def on_message(m):
        if isinstance(m, bytes):
            # audio chunk — write to file or audio output
            ...
        else:
            print(f"event: {getattr(m, 'type', 'Unknown')}")

    conn.on(EventType.OPEN,    lambda _: print("open"))
    conn.on(EventType.MESSAGE, on_message)
    conn.on(EventType.CLOSE,   lambda _: print("close"))
    conn.on(EventType.ERROR,   lambda e: print(f"err: {e}"))

    conn.send_text(SpeakV1Text(text="Hello, this is streaming TTS."))
    conn.send_flush()
    conn.send_close()
    conn.start_listening()   # blocks until server closes

In sync mode, start_listening() blocks — send all text + flush + close BEFORE calling it, OR run it in a thread. In async mode, run start_listening() as a task and send concurrently.

TextBuilder helper (Flux batch controls)

deepgram.helpers.TextBuilder is a hand-maintained helper (NOT Fern-generated) for English Flux batch requests. Pronunciation controls apply to Flux batch, Flux WebSocket, and Aura-2 /v1/speak; pauses are Flux batch-only and a Flux WebSocket rejects them with DATA-0002.

python
from deepgram.helpers import TextBuilder

final_text = (
    TextBuilder()
    .text("Hello,")
    .text(" this is built incrementally.")
    .pronunciation("Deepgram", "ˈdiːpɡɹæm")
    .build()
)

The fluent API is .text(...) (append raw text), .pronunciation(word, ipa) (insert a \{\"word\": \"...\", \"pronounce\": \"...\"\} marker), .pause(duration_ms) (insert a \{pause:<N>ms\} marker), and .build() (return the batch request text). Pauses must be 500-3000 ms in 100 ms increments, with at most eight per request. Pronunciation and pause cannot be combined in one request; Flux rejects the combination with CONTROL_COMBINATION_INVALID. There is no .add(...) method.

Use the output with client.speak.v2.audio.generate(model="flux-alexis-en", text=final_text). See docs/FluxTtsControls.md, examples/22-text-builder-demo.py, and examples/23-text-builder-helper.py.

Async equivalents

python
from deepgram import AsyncDeepgramClient
client = AsyncDeepgramClient()

# REST
audio_iter = await client.speak.v1.audio.generate(text=..., model="aura-2-asteria-en")
async for chunk in audio_iter:
    ...

# WSS
async with client.speak.v1.connect(model="aura-2-asteria-en", ...) as conn:
    listen_task = asyncio.create_task(conn.start_listening())
    await conn.send_text(SpeakV1Text(text="..."))
    await conn.send_flush()
    await conn.send_close()
    await listen_task

Key parameters

REST & WSS: model (e.g. aura-2-asteria-en), encoding (linear16, mulaw, alaw, opus, flac, mp3, aac), sample_rate, bit_rate, container, callback (REST async), tag, mip_opt_out.

WSS client messages: SpeakV1Text, Flush, Clear, Close.

Show full SKILL.md (202 more words)Show less

API reference (layered)

  1. In-repo reference: reference.md — sections "Speak V1 Audio" (REST) and "Speak V1 Connect" (WSS).
  2. OpenAPI (REST): https://developers.deepgram.com/openapi.yaml
  3. AsyncAPI (WSS): https://developers.deepgram.com/asyncapi.yaml
  4. Context7: library ID /llmstxt/developers_deepgram_llms_txt.
  5. Product docs:

Gotchas

  1. Token auth, not Bearer.
  2. REST response is audio bytes, not JSON. Iterate the response; don't .json() it.
  3. Flush before close (WSS). send_close() without send_flush() may drop trailing audio.
  4. Sync start_listening() blocks. Queue all messages first, or use async.
  5. SpeakV1Text is required for WSS text input — don't send raw strings.
  6. encoding/sample_rate/container must match your playback path. Mismatches cause silent failure or distortion.
  7. TextBuilder helpers are hand-maintained (listed in .fernignore as permanently frozen). Don't move them under src/deepgram/ auto-generated paths.

Example files in this repo

  • examples/20-text-to-speech-single.py — REST one-shot
  • examples/21-text-to-speech-streaming.py — WSS streaming
  • examples/22-text-builder-demo.py — TextBuilder (no API key)
  • examples/23-text-builder-helper.py — TextBuilder + REST
  • examples/24-text-builder-streaming.py — plain-text WSS; Flux pause controls are batch-only
  • tests/wire/test_speak_v1_audio.py — REST wire test
  • tests/manual/speak/v1/connect/main.py — live WSS test

Central product skills

For cross-language Deepgram product knowledge — the consolidated API reference, documentation finder, focused runnable recipes, third-party integration examples, and MCP setup — install the central skills:

bash
npx skills add deepgram/skills

This SDK ships language-idiomatic code skills; deepgram/skills ships cross-language product knowledge (see api, docs, recipes, examples, starters, setup-mcp).

© deepgram, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/deepgram-python-text-to-speech of deepgram/deepgram-python-sdk.

Open the folder on GitHubat commit 5c2f3af

Compare with similar skills

Deepgram Python Text-to-Speech next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Deepgram Python Text-to-Speech compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Deepgram Python Text-to-Speech this skilldeepgram/deepgram-python-sdk469—~1.8kAutomated safety check: PassMIT
Speech Engineelevenlabs/skills479—~2.5kAutomated safety check: WarnMIT
Deepgram JS Audio Intelligencedeepgram/deepgram-js-sdk276—~1.5kAutomated safety check: PassMIT
Azure Realtime Podcast Generationmicrosoft/skills3.1k1 repos~947Automated safety check: PassMIT
Grok Realtime Voice Integrationcursor/plugins10k—~1.7kAutomated safety check: PassNone
Arkcli Code Examplevolcengine/ark-cli140—~743Automated safety check: PassApache-2.0

Similar skills

  • Speech Engine

    elevenlabs/skills

    Add real-time voice conversations to a custom agent runtime with ElevenLabs Speech Engine.

    479 GitHub stars~2.5k tokensUpdated yesterday
    Media & CreativeAuto-check: warnings
  • Deepgram JS Audio Intelligence

    deepgram/deepgram-js-sdk

    A skill your agent uses when writing or reviewing JavaScript/TypeScript in this repo that calls Deepgram audio analytics overlays on /v1/listen - summarize, topics, intents, sentiment, diarize…

    276 GitHub stars~1.5k tokensUpdated 5 days ago
    Media & CreativeAuto-check passed
  • Official

    Builds podcast-style audio narration from text with Azure OpenAI's GPT Realtime Mini over WebSocket, from a Python FastAPI backend to a React player.

    3.1k GitHub starsUsed in 1 repo~947 tokens
    Media & CreativeAuto-check passed
  • Official

    Wires Grok speech-to-speech into an app's own microphone and audio playback over a realtime WebSocket, replacing an STT-LLM-TTS cascade or OpenAI Realtime.

    10k GitHub stars~1.7k tokensUpdated yesterday
    Media & CreativeAuto-check passed
  • Arkcli Code Example

    volcengine/ark-cli

    arkcli +code-example:为指定基础模型生成多语言(Python / Go / Java / Node / curl)调用示例代码并写入本地文件。数据源是火山方舟 OpenTOP OpenGetSampleCode。当用户需要拿某个基础模型的 SDK / curl 调用示例、保存为本地接入模板时使用。反触发:TTS/ASR/语音模型没有 arkcli…

    140 GitHub stars~743 tokensUpdated 8 days ago
    Media & CreativeAuto-check passed
  • Deepgram JS Text To Speech

    deepgram/deepgram-js-sdk

    A skill your agent uses when writing or reviewing JavaScript/TypeScript in this repo that calls Deepgram Text-to-Speech v1 (/v1/speak) for audio synthesis.

    276 GitHub stars~1.4k tokensUpdated 5 days ago
    Media & CreativeAuto-check passed

More from deepgram/deepgram-python-sdk

  • Deepgram Audio Intelligence for Python

    deepgram/deepgram-python-sdk

    Shows how to add Deepgram analytics such as diarization, summaries, sentiment, topics, redaction and language detection to speech transcription in Python.

    469 GitHub stars~2.3k tokensUpdated yesterday
    Auto-check passed
  • Deepgram Flux Conversational STT

    deepgram/deepgram-python-sdk

    Writes and reviews Python code for Deepgram's turn-aware streaming speech-to-text (Flux, /v2/listen), including end-of-turn detection.

    469 GitHub stars~1.8k tokensUpdated yesterday
    Auto-check passed
  • Deepgram Python Management API

    deepgram/deepgram-python-sdk

    Guides Python code that calls the Deepgram Management APIs to administer projects, keys, members, usage, billing and stored Voice Agent configurations.

    469 GitHub stars~2.3k tokensUpdated yesterday
    Auto-check passed
  • Deepgram Python Speech-to-Text

    deepgram/deepgram-python-sdk

    Covers basic transcription with the Deepgram Python SDK's listen.v1 endpoint, for one-shot REST transcription of a file or URL and live WebSocket streaming with interim results.

    469 GitHub stars~2.9k tokensUpdated yesterday
    Auto-check passed
  • Deepgram Text Intelligence

    deepgram/deepgram-python-sdk

    Uses the Deepgram Python SDK's Read API to analyze text for sentiment, summaries, topics and intents with client.read.v1.text.analyze, from raw text or a hosted URL.

    469 GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed
  • Deepgram Python Voice Agent

    deepgram/deepgram-python-sdk

    Builds a full-duplex Python voice agent on Deepgram's agent.converse WebSocket, combining speech-to-text, an LLM and text-to-speech with interruption and function calling.

    469 GitHub stars~3.6k tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Deepgram Python Text-to-Speech

What does Deepgram Python Text-to-Speech do?

Guides Python code that calls Deepgram Text-to-Speech v1, covering one-shot REST, streaming WebSocket and the TextBuilder helper. Python code that calls Deepgram Text-to-Speech v1 at /v1/speak is covered along two paths.connect gives low-latency playback while an LLM is still producing tokens.

When should I use Deepgram Python Text-to-Speech?

Deepgram Python Text-to-Speech fits situations like: synthesizing speech from text with the Deepgram Python SDK; streaming audio over a WebSocket while an LLM is still generating; adding pronunciation or pause controls to Flux batch text; reviewing Python code that calls speak.v1.

How do I install Deepgram Python Text-to-Speech in Claude Code?

Run `npx skills add deepgram/deepgram-python-sdk --skill deepgram-python-text-to-speech -a claude-code`. Or copy the skill folder (.agents/skills/deepgram-python-text-to-speech in deepgram/deepgram-python-sdk) into .claude/skills/deepgram-python-text-to-speech in your project. Claude Code loads it when a task matches its description.

How do I install Deepgram Python Text-to-Speech in Codex?

Run `npx skills add deepgram/deepgram-python-sdk --skill deepgram-python-text-to-speech -a codex`. Or copy the skill folder (.agents/skills/deepgram-python-text-to-speech in deepgram/deepgram-python-sdk) into .agents/skills/deepgram-python-text-to-speech in your project. Codex loads it when a task matches its description.

Can I use Deepgram Python Text-to-Speech in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add deepgram/deepgram-python-sdk --skill deepgram-python-text-to-speech -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/deepgram-python-text-to-speech, .gemini/skills/deepgram-python-text-to-speech, .github/skills/deepgram-python-text-to-speech and .opencode/skills/deepgram-python-text-to-speech in your project.

What does Deepgram Python Text-to-Speech need to run?

Going by SKILL.md and its folder, Deepgram Python Text-to-Speech needs the command-line tools its instructions call (npx) and credentials named DEEPGRAM_API_KEY. Our summary lists: A Deepgram API key; Python with the Deepgram SDK.

Does Deepgram Python Text-to-Speech access the network?

SKILL.md names 1 domain. As links in the text: developers.deepgram.com. This is read from the text; nothing was executed.

Is Deepgram Python Text-to-Speech safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Deepgram Python Text-to-Speech use?

Deepgram Python Text-to-Speech is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Deepgram Python Text-to-Speech use?

About 1.8k tokens (SKILL.md is roughly 7.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Deepgram Python Text-to-Speech?

Skills that share tags, products or a category with Deepgram Python Text-to-Speech: Speech Engine (elevenlabs/skills, 479 stars), Deepgram JS Audio Intelligence (deepgram/deepgram-js-sdk, 276 stars), Azure Realtime Podcast Generation (microsoft/skills, 3.1k stars) and Grok Realtime Voice Integration (cursor/plugins, 10k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Deepgram Python Text-to-Speech?

deepgram (a GitHub organization) maintains it in deepgram/deepgram-python-sdk, which has 469 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 6, 2026.

Source: deepgram/deepgram-python-sdk on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.