Creates WAV headers and converts float samples to 16‑bit PCM for stereo audio streams.
// Source: https://github.com/mudler/LocalAI | License: MIT | Copyright 2023-2025 Ettore Di Giacinto (mudler@localai.io) // Provided via justclaw.it.com; keep this notice with the code. package main import ( "bytes" "encoding/binary" "fmt" "os" "github.com/go-audio/audio" "github.com/go-audio/wav" ) // mossttsSampleRate is the MOSS-TTS-Local v1.5 output rate; the engine also // reports it per-synthesis via out_sr, which the writers honour. const mossttsSampleRate = 48000 // mossttsChannels is the MOSS-TTS-Local output layout: 48 kHz stereo, samples // interleaved [L,R,L,R,...]. const mossttsChannels = 2 // wavHeaderStereo returns a 44-byte WAV header for a streaming 16-bit stereo PCM // stream at sampleRate, with placeholder (0xFFFFFFFF) sizes since the total // length is unknow ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key