stt

package
v0.130.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 13 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 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 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, without transcribing or downloading a model. It lets callers fail fast (with an actionable install hint) before recording any 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