voice

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

Available checks if sox/rec is installed.

Types

type Engine

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

func New

func New(openAIKey string) *Engine

func (*Engine) Record deprecated

func (e *Engine) Record(outPath string) error

Record captures audio from the microphone using sox. Equivalent to RecordCtx with context.Background(); kept for back-compat.

Deprecated: prefer RecordCtx so the REPL's turn ctx can abort a stuck recording (Ctrl+C cancels mid-flight instead of waiting for silence).

func (*Engine) RecordCtx added in v0.24.0

func (e *Engine) RecordCtx(ctx context.Context, outPath string) error

RecordCtx captures audio from the microphone using sox until the silence detector fires or the recordTimeout fallback expires. The caller's ctx is honoured: cancelling it kills the rec process. Records 16kHz mono WAV, stops after 1s of silence.

func (*Engine) RecordFixed

func (e *Engine) RecordFixed(outPath string, seconds int) error

RecordFixed captures audio for a fixed duration in seconds.

func (*Engine) Transcribe deprecated

func (e *Engine) Transcribe(audioPath string) (string, error)

Transcribe sends audio to OpenAI Whisper API and returns the text. Equivalent to TranscribeCtx with context.Background().

Deprecated: prefer TranscribeCtx so a network hang can be cancelled.

func (*Engine) TranscribeCtx added in v0.24.0

func (e *Engine) TranscribeCtx(ctx context.Context, audioPath string) (string, error)

TranscribeCtx is the ctx-aware variant of Transcribe.

func (*Engine) TranscribeReader deprecated

func (e *Engine) TranscribeReader(audio io.Reader, filename string) (string, error)

TranscribeReader sends audio from a reader to OpenAI Whisper API. Equivalent to TranscribeReaderCtx with context.Background().

Deprecated: prefer TranscribeReaderCtx — without a cancellable ctx the only timeout is the HTTP client's Timeout field.

func (*Engine) TranscribeReaderCtx added in v0.24.0

func (e *Engine) TranscribeReaderCtx(ctx context.Context, audio io.Reader, filename string) (string, error)

TranscribeReaderCtx sends audio from a reader to OpenAI Whisper API. Honours ctx — cancelling it aborts the in-flight HTTP request so the REPL can return immediately on Ctrl+C even if the API hangs.

Jump to

Keyboard shortcuts

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