deepgram

package
v0.69.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioSettings

type AudioSettings struct {
	// ListenModel names the STT model (e.g. "flux-general-multi", "nova-3").
	ListenModel string
	// SpeakModel names the TTS voice. An "aura-*" voice uses the v1 speak leg;
	// a "flux-*" voice uses the v2 (Flux TTS) leg and is only honoured for
	// English-pinned sessions — see resolveSpeakModel.
	SpeakModel string
	// SpeakSpeed sets the delivery pace (Flux accepts 0.85–1.15 in 0.05 steps).
	SpeakSpeed float64
	// EOTThreshold, EagerEOTThreshold, and EOTTimeoutMs tune Flux's
	// model-integrated end-of-turn detection.
	EOTThreshold      float64
	EagerEOTThreshold float64
	EOTTimeoutMs      int
}

AudioSettings carries the deployment's listen/speak leg selection for ConfigureAudio. Zero values keep the kernel defaults, so a caller can set only the fields its config actually specifies.

type Provider

type Provider struct {
	// Optional overrides; zero values fall back to the package defaults.
	ListenModel   string
	SpeakModel    string
	ThinkProvider string
	ThinkModel    string

	// Flux listen turn-detection tuning. Zero leaves Deepgram's defaults in
	// place; non-zero values are clamped to the documented ranges and are only
	// sent when the listen model is a Flux model (Nova rejects them).
	EOTThreshold      float64
	EagerEOTThreshold float64
	EOTTimeoutMs      int

	// SpeakSpeed adjusts delivery pace on the speak leg. Zero keeps the
	// provider default.
	SpeakSpeed float64

	// ThinkEndpointURL + ThinkAPIKey switch the think leg to a bring-your-own
	// LLM deployment. When ThinkEndpointURL is set, the Settings message carries
	// an agent.think.endpoint block so Deepgram calls the operator's own LLM
	// instead of a Deepgram-managed model; ThinkAPIKey (when set) is sent as an
	// "Authorization: Bearer <key>" header on that endpoint. Leave both empty to
	// use Deepgram's managed LLM for ThinkProvider/ThinkModel (no key needed).
	ThinkEndpointURL string
	ThinkAPIKey      string
	// contains filtered or unexported fields
}

Provider implements live.LiveProvider against the Deepgram Voice Agent API (WebSocket). It mirrors GeminiLive/OpenAILive's surface so callers don't need to know which backend is active.

The think (LLM) leg is configurable: Deepgram drives the LLM server-side, so ThinkProvider/ThinkModel select which model reasons over the transcript. Defaults target a widely-available option; the wiring layer overrides them from deployment config. Listen defaults to Deepgram Flux for turn-aware conversational STT and speak defaults to a Deepgram Aura-2 voice.

func New

func New() *Provider

New returns a fresh Deepgram Voice Agent provider.

func (*Provider) Close added in v0.64.3

func (p *Provider) Close() error

Close terminates the WebSocket and stops the keepalive loop. Idempotent.

func (*Provider) ConfigureAudio added in v0.64.3

func (p *Provider) ConfigureAudio(s AudioSettings)

ConfigureAudio applies the deployment's listen/speak selection and Flux turn-detection tuning to the provider. Empty/zero fields keep the kernel defaults. Both Targets call this from their Voice Agent wiring alongside ConfigureThink.

func (*Provider) ConfigureThink added in v0.64.3

func (p *Provider) ConfigureThink(provider, model, endpointURL, apiKey string)

ConfigureThink applies the deployment's think-LLM selection to the provider. Non-empty provider/model override the package defaults; empty values keep the Deepgram-managed default. endpointURL/apiKey select a bring-your-own think LLM (see ThinkEndpointURL/ThinkAPIKey) and are cleared when empty. Both Targets call this from their Voice Agent wiring with values resolved from config.

func (*Provider) Connect added in v0.64.3

func (p *Provider) Connect(ctx context.Context, cfg live.LiveConfig) error

Connect dials the Deepgram Voice Agent WebSocket and sends the initial Settings message describing listen/think/speak and the audio formats. The SettingsApplied acknowledgement is consumed asynchronously by Receive().

func (*Provider) Name added in v0.64.3

func (p *Provider) Name() string

Name identifies the provider in Voice Agent logs.

func (*Provider) Receive added in v0.64.3

func (p *Provider) Receive(ctx context.Context) (*live.LiveMessage, error)

Receive translates the next server frame into a live.LiveMessage. Binary frames are agent audio; text frames are JSON control events. Events that don't map to live.LiveMessage fields are swallowed and the loop fetches the next frame.

func (*Provider) SendAudio added in v0.64.3

func (p *Provider) SendAudio(chunk []byte) error

SendAudio forwards a 16 kHz PCM16 mic chunk as a binary frame. Deepgram accepts the mic rate directly (declared in the Settings input config), so no resample is needed. Empty chunks are no-ops.

func (*Provider) SendAudioStreamEnd added in v0.64.3

func (p *Provider) SendAudioStreamEnd() error

SendAudioStreamEnd is a no-op for Deepgram: the Voice Agent performs its own endpointing/turn-detection server-side and responds when the user stops speaking. There is no client-side commit in the protocol.

func (*Provider) SendText added in v0.64.3

func (p *Provider) SendText(text string) error

SendText injects a text user turn (e.g. an idle reminder) and lets the agent respond. Empty text is a no-op.

func (*Provider) SendToolResponse added in v0.64.3

func (p *Provider) SendToolResponse(response live.ToolResponse) error

SendToolResponse returns a host-side function result to the agent.

func (*Provider) SessionCapabilities added in v0.64.3

func (p *Provider) SessionCapabilities() live.SessionCapabilities

func (*Provider) UpdateInstructions added in v0.64.3

func (p *Provider) UpdateInstructions(ctx context.Context, cfg live.LiveConfig) error

UpdateInstructions refreshes the agent's system prompt without a reconnect. Implements live.LiveInstructionUpdater.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL