Documentation
¶
Overview ¶
Package audiocpp is a Go binding for audio.cpp's TTS engine, loaded in-process via purego (no cgo) over the extern "C" shim in shim/audiocpp_c.h. It mirrors a common purego binding approach.
The surface is deliberately small (five C symbols), so — unlike sd-go, which splits a ~50-symbol API into pkg/sd + a root layer — the raw bindings and the ergonomic API live in one package here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeWAV ¶
EncodeWAV encodes an Audio result as a 16-bit PCM WAV file (little-endian). A convenience for callers/examples; the worker ships base64 WAV to the API.
func Load ¶
Load resolves and dlopens the audiocpp shared library from libDir (an empty libDir falls back to the OS default search path). It is idempotent, safe for concurrent use, and returns an error — never panics — when the library is absent or a symbol is missing, so importing this package or calling Load with no library present keeps the caller healthy.
Types ¶
type Error ¶
Error is a synthesis or load failure from the engine. Code is the coarse shim status (see the shim's audiocpp_status); Msg is the engine's free-text message. The whole point of the in-process binding over the old HTTP path is that this arrives synchronously — no status code to re-parse off a response.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is a loaded TTS model. It is NOT safe for concurrent use — synthesise serially — hold one model behind a single-slot mutex. An internal mutex is kept only to prevent a use-after-free race between Synthesize and Close, not to enable parallelism.
func New ¶
func New(p ModelParams) (m *Model, err error)
New loads a model. The returned Model must be Close()d to free native memory.
func (*Model) Synthesize ¶
func (m *Model) Synthesize(p SynthParams) (a *Audio, err error)
Synthesize turns text into audio. Safe against a concurrent Close (returns an error if the model is closed); concurrent Synthesize calls are serialized.
type ModelParams ¶
type ModelParams struct {
ModelPath string // path to the GGUF (required)
FamilyHint string // audio.cpp family, e.g. "qwen3_tts"
Backend string // "cpu"|"metal"|"cuda"|"vulkan"|"hip"|"best" ("" == cpu)
Device int // GPU device index
Threads int // CPU threads (<=0 -> engine default)
LoadOptions map[string]string // extra load-time options
}
ModelParams configures a model load.
type SynthParams ¶
type SynthParams struct {
Task string // "tts" (default) | "voice_design" | "voice_clone"
Text string // text to speak (required)
VoiceID string // preset speaker id, e.g. "ryan"
RefPCM []float32 // reference-audio voice (mono f32); alternative to VoiceID
RefSampleRate int // sample rate of RefPCM
Options map[string]string // per-request options (instruct, seed, temperature, ...)
}
SynthParams configures one synthesis call.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
tts
command
Command tts is a minimal end-to-end example: load a model and synthesise a WAV, exercising the Go -> shim -> engine path end to end.
|
Command tts is a minimal end-to-end example: load a model and synthesise a WAV, exercising the Go -> shim -> engine path end to end. |