run

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Overview

Package run holds the shared scaffolding for the per-provider voice examples under examples/voice. Each example wires one provider stack explicitly in Go and calls Voice; this package owns the WebRTC transport, the STT -> LLM -> TTS pipeline, turn-taking and barge-in, and the HTTP server.

jargo itself reads no environment variables: the library takes explicit Config structs. The examples follow the same rule — the provider and its settings are written out in Go; only the API key secret is read from the environment, the way you would source any secret.

Index

Constants

View Source
const SampleRate = opus.SampleRate

SampleRate is the audio sample rate the examples run at (Opus full-band).

Variables

This section is empty.

Functions

func Build

func Build[C interface{ Validate() error }, S processor.Processor](cfg C, ctor func(C) S) (processor.Processor, error)

Build validates cfg and, when valid, constructs the service with ctor. It keeps each provider's builder to a single line and makes a misconfigured provider fail fast with a clear error rather than at the first request.

func DefaultLLM

func DefaultLLM() (processor.Processor, error)

DefaultLLM builds the default LLM service (Anthropic), reading ANTHROPIC_API_KEY.

func DefaultSTT

func DefaultSTT() (processor.Processor, error)

DefaultSTT builds the default STT service (Deepgram), reading DEEPGRAM_API_KEY.

func DefaultTTS

func DefaultTTS() (processor.Processor, error)

DefaultTTS builds the default TTS service (ElevenLabs), reading ELEVENLABS_API_KEY.

func Voice

func Voice(b Builders) error

Voice serves the voice bot on :8080 (override with the ADDR env var), building a fresh STT/LLM/TTS stack from b for each browser connection. It blocks until the server exits. Open the URL it logs, click start, and allow the mic.

Types

type Builder

type Builder = func() (processor.Processor, error)

Builder constructs one service. It is called once per connection so each caller gets a fresh STT/LLM/TTS — the STT and TTS services hold a per-session stream and must not be shared between connections.

func Service

func Service[C interface{ Validate() error }, S processor.Processor](cfg C, ctor func(C) S) Builder

Service returns a Builder that, on each call, validates cfg and constructs the service with ctor. Use it to wire a provider in one line, e.g.

TTS: run.Service(cartesia.Config{APIKey: os.Getenv("CARTESIA_API_KEY")}, cartesia.NewTTS),

type Builders

type Builders struct {
	STT Builder
	LLM Builder
	TTS Builder
}

Builders is the per-connection STT/LLM/TTS stack for an example. Use Service (or the Default* builders) to fill it in.

Jump to

Keyboard shortcuts

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