deepgram/deepgram-go-sdk · Archived

deepgram-go-text-to-speech

Use when writing or reviewing Go code in this repo that synthesizes audio with Speak v1 REST or Speak WebSockets.

First seen May 31, 2026

Installation

$ npx skills add deepgram/deepgram-go-sdk --skill deepgram-go-text-to-speech

Summary

  • Use when writing or reviewing Go code in this repo that synthesizes audio with Speak v1 REST or Speak WebSockets.
  • Route transcription work to deepgram-go-speech-to-text, voice conversation runtime work to deepgram-go-voice-agent, and repository maintenance work to deepgram-go-maintaining-sdk.

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from deepgram/deepgram-go-sdk.

npx skills add deepgram/deepgram-go-sdk

Browse all from deepgram/deepgram-go-sdk

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 89
License LICENSE
Default branch main
Open issues 30
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 5,026 B
  • docs SUMMARY.md 327 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 7 installs

SKILL.md

Using Deepgram Text-to-Speech from the Go SDK

When to use this product

Use this skill for pkg/client/speak work:

  • file or stream synthesis over REST
  • low-latency synthesis over WebSockets
  • callback-based or channel-based audio playback pipelines

Use a different skill when:

  • you need STT (deepgram-go-speech-to-text)
  • you need live voice-agent orchestration (deepgram-go-voice-agent)
  • you need repo workflow guidance (deepgram-go-maintaining-sdk)

Authentication

Set DEEPGRAMAPIKEY before creating Speak clients.

export DEEPGRAM_API_KEY="your_api_key"

Use the repo's env-backed client defaults instead of embedding secrets in code.

Quick start

REST synthesis to file:

package main

import (
	"context"
	"log"

	api "github.com/deepgram/deepgram-go-sdk/v3/pkg/api/speak/v1/rest"
	speak "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/speak"
	interfaces "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/interfaces"
)

func main() {
	if err := run(); err != nil {
		log.Fatal(err)
	}
}

func run() error {
	ctx := context.Background()

	client := speak.NewRESTWithDefaults()
	dg := api.New(client)

	if _, err := dg.ToSave(
		ctx,
		"hello.wav",
		"Hello from the Deepgram Go SDK.",
		&interfaces.SpeakOptions{Model: "aura-2-thalia-en"},
	); err != nil {
		return err
	}

	return nil
}

Streaming synthesis with callbacks or channels:

package main

import (
	"context"
	"fmt"
	"log"

	speakws "github.com/deepgram/deepgram-go-sdk/v3/pkg/api/speak/v1/websocket"
	speak "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/speak"
	interfaces "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/interfaces"
)

func main() {
	if err := run(); err != nil {
		log.Fatal(err)
	}
}

func run() error {
	ctx := context.Background()
	handler := speakws.NewDefaultChanHandler()

	conn, err := speak.NewWSUsingChanWithDefaults(
		ctx,
		&interfaces.WSSpeakOptions{Model: "aura-2-thalia-en"},
		handler,
	)
	if err != nil {
		return err
	}
	defer conn.Stop()

	if ok := conn.Connect(); !ok {
		return fmt.Errorf("connect failed")
	}

	conn.Start()

	if err := conn.SpeakWithText("Streaming TTS from Go."); err != nil {
		return err
	}

	// The handler receives binary audio and flow-control events.
	if err := conn.Flush(); err != nil {
		return err
	}

	return nil
}

Key parameters

  • interfaces.SpeakOptions

- typical fields: Model, Encoding, Container, SampleRate

  • interfaces.WSSpeakOptions

- typical fields: Model, streaming audio format settings

  • REST methods

- via pkg/api/speak/v1/rest: api.New(client).ToStream, ToFile, ToSave

  • WS methods

- SpeakWithText, Speak, Flush, Reset

  • constructors

- speak.NewRESTWithDefaults() / speak.NewREST(...) - speak.NewWSUsingCallback... - speak.NewWSUsingChan...

API reference (layered)

  1. In-repo reference

- README.md - docs.go - pkg/client/speak/client.go - pkg/client/speak/v1/rest/client.go - pkg/client/speak/v1/websocket/clientcallback.go - pkg/client/speak/v1/websocket/clientchannel.go - pkg/client/interfaces/v1/types-speak.go

  1. OpenAPI

- https://developers.deepgram.com/openapi.yaml

  1. AsyncAPI

- https://developers.deepgram.com/asyncapi.yaml

  1. Context7

- /llmstxt/developersdeepgramllms_txt

  1. Product docs

- https://developers.deepgram.com/reference/text-to-speech/speak-request - https://developers.deepgram.com/reference/text-to-speech/speak-streaming - https://developers.deepgram.com/docs/tts-models

Gotchas

  1. REST and WebSocket Speak clients use different option structs.
  2. REST methods live on pkg/api/speak/v1/rest; build them with api.New(client).
  3. WebSocket flows use a handler passed at construction, Connect() returns bool, and shutdown is Stop().
  4. Keep the playback or message-consumer goroutine running while audio frames arrive.
  5. Follow the examples for file handling and output format selection instead of guessing encodings.

Example files in this repo

  • examples/text-to-speech/rest/file/hello-world/main.go
  • examples/text-to-speech/websocket/simple_channel/main.go
  • examples/text-to-speech/websocket/simple_callback/main.go

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:

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).