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 ¶
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 ¶
Transcribe converts the audio at wavPath (16kHz mono WAV) into text.