audio

package
v0.270.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 18 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.

README

audio

What - the audio capability: recording microphone speech to a WAV, and reading the length of a WAV. Why - recording runs ffmpeg (or arecord/sox) with its own device and silence handling, none of which belong in the agent loop. How - the container wires the recorder into the voice shortcut, which hands the WAV to the agent's transcription service, and TextToSpeech reports the length of the WAV the gateway returned.

How it plugs in

  • speech_to_text enables the voice shortcut and the transcription of Telegram voice messages. Both transcribe through the gateway's transcription API with transcribe.model.
  • Speech synthesis is not here: TextToSpeech goes through the agent's speech service to the gateway.
  • Music, sound effects and video are not here: those tools call the gateway through the agent's media ports.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WAVDurationSeconds added in v0.184.0

func WAVDurationSeconds(path string) (float64, error)

WAVDurationSeconds returns the duration of a RIFF/WAVE file in seconds by reading its fmt and data chunk headers. It lets callers report the duration of synthesized speech without external tools.

Types

type Recorder

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

Recorder captures microphone audio into a 16kHz mono WAV file through ffmpeg, with arecord and sox fallbacks on Linux, and adds no CGO. run, runSilence and lookPath are overridable in tests.

func NewRecorder

func NewRecorder(cfg config.SpeechToTextConfig) *Recorder

NewRecorder creates a Recorder from the speech-to-text config.

func (*Recorder) EnsureAvailable

func (r *Recorder) EnsureAvailable() error

EnsureAvailable reports whether a microphone capture tool can be resolved (possibly by downloading ffmpeg), without recording. It lets callers fail fast (with an actionable error) before prompting the user to speak.

func (*Recorder) Record

func (r *Recorder) Record(ctx context.Context, maxSeconds int) (string, error)

Record captures up to maxSeconds of microphone audio and returns the path to a 16kHz mono WAV file. When speech_to_text.silence_timeout is set, ffmpeg recordings stop shortly after the speaker goes quiet instead of always running for the full cap. The caller owns the returned file and should remove it.

Jump to

Keyboard shortcuts

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