Help us shape the future of Go! Take the 2026 Go Developer Survey

transcribe

package
v1.152.0 Latest Latest
Warning

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

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

Documentation

Overview

Package transcribe provides real-time audio transcription using OpenAI's Realtime API.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("speech-to-text is only supported on macOS")

ErrNotSupported is returned when transcription is unavailable on this platform.

Functions

This section is empty.

Types

type Transcriber

type Transcriber struct {
	// contains filtered or unexported fields
}

Transcriber holds configuration; each Run owns its connection and audio capture.

func New

func New(apiKey string) *Transcriber

New creates a transcriber without opening a connection or microphone.

func (*Transcriber) IsSupported

func (t *Transcriber) IsSupported() bool

IsSupported reports whether microphone capture is available on this platform.

func (*Transcriber) Run added in v1.152.0

func (t *Transcriber) Run(ctx context.Context, finish <-chan struct{}, handler TranscriptHandler, ready func(context.Context)) (err error)

Run aborts promptly on ctx cancellation. Closing finish stops capture, drains captured audio, and waits up to ten seconds for final transcription. A nil finish channel disables graceful finishing. Finishing before connection setup completes cancels setup without starting capture.

Ready runs after capture starts, with a context canceled on finish or abort. Transcript handlers remain active during finish. Callbacks must honor their contexts; Run joins them and capture cleanup before returning. Cancellation itself returns nil, but capture, server and finalization errors are preserved.

type TranscriptHandler

type TranscriptHandler func(ctx context.Context, delta string)

TranscriptHandler receives completed transcripts in audio commit order. It must return when ctx is canceled.

Jump to

Keyboard shortcuts

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