Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyText is returned when there is nothing to synthesize. ErrEmptyText = errors.New("tts: empty text") // ErrNotConfigured is returned when the engine binary or model is missing. ErrNotConfigured = errors.New("tts: engine not configured (piper binary or model missing)") )
Functions ¶
func DetectLanguage ¶ added in v1.15.0
DetectLanguage returns the ISO 639-1 code of text's dominant language, restricted to candidates (the languages you have a voice/model for). Restricting the choice makes detection far more accurate on short or mixed text than open-set detection. With a single candidate it returns that language without detecting; with none, or when it can't decide, it returns "".
func ResolveEngine ¶ added in v1.15.0
ResolveEngine maps a configured engine value to a concrete engine. "say" and "piper" are honored as-is; anything else ("" or "auto") auto-selects by OS: macOS gets the built-in "say" (zero dependencies, always available), every other platform gets the cross-platform "piper".
Types ¶
type ExternalPiperSynthesizer ¶
type ExternalPiperSynthesizer struct {
PiperPath string
}
ExternalPiperSynthesizer runs the local Piper binary: text on stdin → a temp WAV file.
func (*ExternalPiperSynthesizer) Synthesize ¶
func (s *ExternalPiperSynthesizer) Synthesize(ctx context.Context, text string, opts SynthesizeOptions) (*SynthesisResult, error)
type SaySynthesizer ¶ added in v1.15.0
type SaySynthesizer struct{}
SaySynthesizer uses the macOS built-in `say` command — zero external dependencies, always available on macOS. It speaks **directly** (streaming): `say` starts talking almost immediately and is killed instantly on cancel, with no temp file or separate player. opts.ModelPath is ignored; opts.Voice selects a macOS system voice (the caller picks it by detected language). Because it plays itself, Synthesize returns an empty AudioPath — the SpeechService takes that as "already played".
func (*SaySynthesizer) Synthesize ¶ added in v1.15.0
func (s *SaySynthesizer) Synthesize(ctx context.Context, text string, opts SynthesizeOptions) (*SynthesisResult, error)
type SynthesisResult ¶
SynthesisResult describes the generated audio.
type SynthesizeOptions ¶
type SynthesizeOptions struct {
ModelPath string // path to the .onnx voice model (engine "piper")
Voice string // voice name (engine "say"); empty = system default
}
SynthesizeOptions configures a single synthesis call. The fields are per-call so the caller can pick a voice/model by the detected language of the text.
type Synthesizer ¶
type Synthesizer interface {
Synthesize(ctx context.Context, text string, opts SynthesizeOptions) (*SynthesisResult, error)
}
Synthesizer turns text into an audio file. Decoupled so the engine can be swapped.