assemblyai

package
v0.76.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package assemblyai adapts the AssemblyAI speech-to-text products to stt.STTProvider: the synchronous endpoint on sync.assemblyai.com for short dictation clips, the async upload-and-poll API on api.assemblyai.com for everything else (diarization, speaker identification, redaction), and the v3 realtime WebSocket for live dictation and speaker streams. It needs an AssemblyAI API key and public https egress; there is no local component.

Stability: Beta — API-checked; may change with a changelog callout.

Index

Constants

View Source
const DefaultTurnCleanupPrompt = "" /* 164-byte string literal not displayed */

DefaultTurnCleanupPrompt asks the gateway to tidy a single turn without summarizing. {{turn}} is substituted by AssemblyAI.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options added in v0.74.0

type Options struct {
	// APIKey is the AssemblyAI API key.
	APIKey string
	// Models is the comma-separated model fallback list. Empty selects the
	// provider default.
	Models string
}

Options configures New.

type Provider

type Provider struct {
	APIKey           string
	Models           []string
	StreamingModel   string
	BaseURL          string
	StreamingBaseURL string
	// SyncBaseURL points at the synchronous transcription endpoint
	// (https://sync.assemblyai.com; regional variants sync.us / sync.eu
	// exist). The Sync API returns a finished Universal-3.5 Pro transcript
	// in one request/response (~134 ms p50) for clips up to 120 s / 40 MB —
	// the low-latency dictation path. Empty uses the global endpoint.
	SyncBaseURL string
	// SyncModel is the X-AAI-Model routing header value for sync requests.
	// Empty uses universal-3-5-pro.
	SyncModel string
	// DisableSync forces every transcription through the classic async
	// upload+poll flow, even for clips the Sync API could serve.
	DisableSync bool
	// StreamingLLM, when set, attaches AssemblyAI LLM Gateway to Universal-3.5
	// Pro realtime turns. The formatted transcript still arrives as Turn;
	// LLMGatewayResponse may rewrite the final text for live cleanup.
	StreamingLLM *StreamingLLM
	Validation   netsec.ValidationOptions
	PollInterval time.Duration
	PollTimeout  time.Duration
	// Logger receives this provider's diagnostics. Nil falls back to
	// slog.Default() at log time.
	Logger *slog.Logger
	// contains filtered or unexported fields
}

Provider transcribes through AssemblyAI.

func New

func New(opts Options) *Provider

New creates an AssemblyAI provider. Zero Options values select the provider defaults.

func (*Provider) Capabilities added in v0.64.3

func (*Provider) Capabilities() []speechkit.Capability

Capabilities reports what this provider does beyond plain transcription: besides separating voices it attributes them to caller-supplied names or roles.

func (*Provider) EnableStreamingLLM added in v0.64.3

func (p *Provider) EnableStreamingLLM(model, prompt string, maxTokens int)

EnableStreamingLLM attaches LLM Gateway cleanup to realtime dictation.

func (*Provider) Health added in v0.64.3

func (p *Provider) Health(ctx context.Context) error

Health issues an authenticated GET on the transcript collection; a transport failure or non-200 status is returned as the error.

func (*Provider) Name added in v0.64.3

func (p *Provider) Name() string

Name returns "assemblyai".

func (*Provider) StartDictationStream added in v0.64.3

StartDictationStream opens a Universal-3.5 Pro realtime session for live dictation partials. DictationStreamOptions.PromptHint rides as agent_context — the "minimal situational info" (domain, audience, locale hints) the model conditions on from the first frame; finalized user turns are carried forward by the provider automatically. Finalize sends Terminate: the provider flushes the trailing turn, emits Termination, and closes the socket (Receive then returns io.EOF), which matches SpeechKit's one-provider-stream-per-segment model.

func (*Provider) StartSpeakerStream added in v0.64.3

func (p *Provider) StartSpeakerStream(ctx context.Context, opts speaker.Options, format speaker.AudioFormat) (speaker.SpeakerStream, error)

StartSpeakerStream implements speaker.StreamingProvider over the v3 realtime WebSocket with speaker labels on. opts must ask for diarization; a single streaming speech model is picked from opts.Model, the provider's StreamingModel or the flagship default (batch-only ids are skipped), and the expected speaker count bounds max_speakers.

func (*Provider) Transcribe added in v0.64.3

func (p *Provider) Transcribe(ctx context.Context, audio []byte, opts stt.TranscribeOpts) (*stt.Result, error)

Transcribe implements stt.STTProvider. Short plain clips go through the synchronous endpoint in one request; clips that need async-only features (diarization, speaker identification, PII redaction, the medical domain) or exceed the sync limits take the upload, create and poll flow, as does any clip whose sync attempt failed (that error stays in the returned error chain). The language defaults to German unless resolved otherwise, and the result Model lists the model fallback chain sent to AssemblyAI.

func (*Provider) Warm added in v0.64.3

func (p *Provider) Warm(ctx context.Context) error

Warm pre-establishes the HTTPS connection to the Sync API (DNS, TCP, TLS) so the subsequent /transcribe request skips connection setup. Hosts should call it when recording starts; the endpoint is unauthenticated and safe to call repeatedly, and idle connections are evicted after seconds to minutes, so warm close to the transcription rather than at startup.

type StreamingLLM

type StreamingLLM struct {
	Model     string
	Prompt    string
	MaxTokens int
}

StreamingLLM is the LLM Gateway payload attached to a realtime dictation WebSocket. Model IDs are LLM Gateway catalog names, not STT names.

Jump to

Keyboard shortcuts

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