Documentation
¶
Overview ¶
Package transcribe provides real-time audio transcription using OpenAI's Realtime API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
TranscriptHandler receives completed transcripts in audio commit order. It must return when ctx is canceled.