stt

package
v0.161.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package stt provides CGO-free speech-to-text by shelling out to a local whisper.cpp binary (whisper-cli / whisper-cpp) and downloading GGML models on demand. It is gated by config.SpeechToTextConfig and used by the chat /voice shortcut and by Telegram voice-message transcription.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryManager added in v0.148.0

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

BinaryManager downloads prebuilt STT helper binaries (whisper-cli, ffmpeg) into ~/.infer/bin on demand, mirroring ModelManager for GGML models.

func NewBinaryManager added in v0.148.0

func NewBinaryManager(cfg config.SpeechToTextConfig) *BinaryManager

NewBinaryManager creates a BinaryManager from the speech-to-text config.

func (*BinaryManager) EnsureBinary added in v0.148.0

func (b *BinaryManager) EnsureBinary(ctx context.Context, name string) (string, error)

EnsureBinary returns the local path to the named binary under ~/.infer/bin, downloading it (checksum-verified) on first use when auto_download is enabled. An existing file is returned as-is.

type FileTranscriber

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

FileTranscriber transcribes an arbitrary audio file by first converting it to 16kHz mono WAV with ffmpeg, then running Whisper. It is used for Telegram voice messages (OGG/Opus), which must be decoded before transcription.

func NewFileTranscriber

func NewFileTranscriber(cfg config.SpeechToTextConfig) *FileTranscriber

NewFileTranscriber creates a FileTranscriber from the speech-to-text config.

func (*FileTranscriber) TranscribeFile

func (f *FileTranscriber) TranscribeFile(ctx context.Context, audioPath string) (string, error)

TranscribeFile converts audioPath to WAV and returns its transcription. The intermediate WAV file is removed before returning.

type ModelManager

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

ModelManager resolves and (optionally) downloads the GGML model file.

func NewModelManager

func NewModelManager(cfg config.SpeechToTextConfig) *ModelManager

NewModelManager creates a ModelManager from the speech-to-text config.

func (*ModelManager) EnsureModel

func (m *ModelManager) EnsureModel(ctx context.Context) (string, error)

EnsureModel returns the local path to the model file, downloading it on first use when AutoDownload is enabled. Downloads are cached; an existing file is returned as-is.

type WhisperTranscriber

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

WhisperTranscriber transcribes a 16kHz mono WAV file using whisper.cpp.

func NewWhisperTranscriber

func NewWhisperTranscriber(cfg config.SpeechToTextConfig) *WhisperTranscriber

NewWhisperTranscriber creates a transcriber from the speech-to-text config.

func (*WhisperTranscriber) EnsureAvailable

func (w *WhisperTranscriber) EnsureAvailable() error

EnsureAvailable reports whether the whisper binary can be resolved (possibly by downloading it), without transcribing or downloading a model. It lets callers fail fast (with an actionable install hint) before recording audio.

func (*WhisperTranscriber) Transcribe

func (w *WhisperTranscriber) Transcribe(ctx context.Context, wavPath string) (string, error)

Transcribe converts the audio at wavPath (16kHz mono WAV) into text.

Jump to

Keyboard shortcuts

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