audioio

package
v0.209.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 7 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 audioio converts a local audio (or video) file into the 16 kHz mono 16-bit PCM WAV that whisper.cpp expects, using ffmpeg. It drops any video stream (-vn) so a video source only ships its audio downstream, and NEVER fetches a remote URL — only local files. Mirrors internal/videoio.

Index

Constants

This section is empty.

Variables

View Source
var ErrFFmpegUnavailable = errors.New("ffmpeg could not be run")

ErrFFmpegUnavailable is what a conversion returns when ffmpeg could not be run at all (the executable is not on the PATH, the configured path is wrong or not executable), as opposed to ffmpeg running and refusing the input. The first is the stack's fault and the second the caller's file: a ledger row that filed both as "bad input" (F22 follow-up) would send an operator to look at a file when the box has no ffmpeg. errors.Is(err, ErrFFmpegUnavailable) lets a door file it as ffmpeg_unavailable.

View Source
var ErrNoAudioStream = errors.New("the input has no audio stream")

ErrNoAudioStream is what a conversion returns for an input that has no audio stream to convert: a silent screen recording, a video without a track, a picture. ffmpeg's own words for it are "Output file does not contain any stream" with exit status 234 (the output has nothing to hold once -vn has dropped the video), which read as an ffmpeg failure to everything above this package (F21, 2026-10-09: a transcription deferred with that raw text). It is a fact about the caller's file, not about ffmpeg or the stack: errors.Is(err, ErrNoAudioStream) lets a door say so and file it as a bad input.

Functions

func ConvertToOpus16k added in v0.206.0

func ConvertToOpus16k(audioPath, ffmpegPath string) (string, func(), error)

ConvertToOpus16k transcodes audioPath to a 16 kHz mono Opus/Ogg file at about 32 kbps in a fresh temp dir and returns its path plus a cleanup func that removes the dir (safe to call twice). It is the form a transcription travels in to a fleet node (the stt upload door): about 14 MB per hour of speech where the 16 kHz WAV the local path feeds whisper is 115 MB. ffmpegPath is the ffmpeg executable ("" => "ffmpeg"). A missing input or an ffmpeg failure (a build without libopus included) returns an error and leaves nothing behind; the caller may then send the original file.

func ConvertToWav16k

func ConvertToWav16k(audioPath, ffmpegPath string) (string, func(), error)

ConvertToWav16k transcodes audioPath to a 16 kHz mono PCM WAV in a fresh temp dir and returns the wav path plus a cleanup func that removes the temp dir. ffmpegPath is the ffmpeg executable ("" => "ffmpeg"). The caller MUST defer cleanup() (it is also safe to call twice). A missing input or an ffmpeg failure returns an error and leaves nothing behind.

Types

This section is empty.

Jump to

Keyboard shortcuts

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