Documentation
¶
Overview ¶
Package audio provides the shared PCM audio primitives for the SpeechKit capture format: 16kHz S16 mono constants, WAV framing, duration math, and RMS level estimation.
Stability: Stable — no breaking change without a minor version bump and a changelog callout.
Index ¶
- Constants
- func NormalizePCM16Mono(pcm []byte, srcRate, srcCh, dstRate int) ([]byte, error)
- func PCMDurationSecs(pcm []byte) float64
- func PCMLevel(pcm []byte) float64
- func PCMToWAV(pcm []byte) []byte
- func ParseWAV(raw []byte) (pcm []byte, sampleRate, channels int, err error)
- func SynthesizedToPCM16Mono(raw []byte, format string, sourceRate, dstRate int) ([]byte, error)
Constants ¶
const ( SampleRate = 16000 Channels = 1 BitsPerSample = 16 BytesPerSample = BitsPerSample / 8 )
PCM format of every SpeechKit capture buffer: 16 kHz sample rate, one channel, signed 16-bit little-endian samples, so a second of audio is SampleRate*BytesPerSample (32000) bytes.
Variables ¶
This section is empty.
Functions ¶
func NormalizePCM16Mono ¶ added in v0.76.6
NormalizePCM16Mono downmixes multi-channel S16LE PCM to mono and resamples it to dstRate.
func PCMDurationSecs ¶
PCMDurationSecs returns the duration of PCM audio in seconds.
func ParseWAV ¶ added in v0.76.6
ParseWAV returns the S16LE data chunk of a PCM WAV file with its native sample rate and channel count.
func SynthesizedToPCM16Mono ¶ added in v0.76.6
SynthesizedToPCM16Mono converts one synthesized speech payload (WAV, MP3 or raw S16LE PCM at sourceRate) to S16LE mono PCM at dstRate, the shape a raw PCM audio wire expects. Formats it cannot decode, such as Opus, fail rather than pass through as unplayable bytes.
Types ¶
This section is empty.