audio

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 5 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 audio transcodes the raw PCM emitted by Gemini TTS into the OGG/Opus container chat apps such as Telegram render as a voice message.

It shells out to ffmpeg: there is no production-quality pure-Go Opus encoder, and CGO would break static builds.

Index

Constants

View Source
const MinClipMillis = 1500

MinClipMillis is the minimum clip duration: some chat platforms reject sub-~1s clips as audio messages, so short clips are padded with trailing silence up to this length.

Variables

View Source
var ErrFFmpegMissing error = ffmpegMissingError{}

ErrFFmpegMissing is returned when the ffmpeg binary is not available on PATH.

Functions

func Available

func Available() bool

Available reports whether the ffmpeg binary can be found on PATH.

func EncodePCMToOggOpus

func EncodePCMToOggOpus(ctx context.Context, pcm []byte, sampleRate int) ([]byte, error)

EncodePCMToOggOpus converts 16-bit little-endian signed mono PCM at the given sample rate into an OGG/Opus file suitable for voice-message playback.

func PCMDurationMs

func PCMDurationMs(pcm []byte, sampleRate int) int

PCMDurationMs returns the duration of 16-bit mono PCM at the given rate.

func TripleOggWithGap

func TripleOggWithGap(ctx context.Context, in []byte, gapMillis int) ([]byte, error)

TripleOggWithGap returns an OGG/Opus that plays the input clip three times separated by gapMillis of silence, padded to MinClipMillis. Lengthens stored short clips (a single word/sound) so strict platforms accept them, without re-TTS.

Types

This section is empty.

Jump to

Keyboard shortcuts

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