tts

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTTSLoadError

func CheckTTSLoadError() (error, bool)

CheckTTSLoadError returns any TTS loading error if loading has completed. Returns (nil, false) if loading is still in progress. Returns (err, true) if loading completed (err may be nil if successful). This is safe to call from the main thread for UI error display.

func PreloadTTSModel

func PreloadTTSModel(lg *log.Logger, targetSampleRate int)

func SynthesizeContactTTS

func SynthesizeContactTTS(text, voice string, radioSeed uint32) ([]int16, error)

SynthesizeContactTTS generates PCM audio for a contact using the low-priority TTS instance. The radioSeed determines per-aircraft radio characteristics so the same aircraft has a consistent sound.

func SynthesizeReadbackTTS

func SynthesizeReadbackTTS(text, voice string, radioSeed uint32) ([]int16, error)

SynthesizeReadbackTTS generates PCM audio for a readback using the high-priority TTS instance. The radioSeed determines per-aircraft radio characteristics so the same aircraft has a consistent sound.

Types

type Config

type Config struct {
	ModelPath    string
	VoicesPath   string
	TokensPath   string
	DataDir      string
	DictDir      string
	LexiconPath  string
	Lang         string
	NumThreads   int
	LowPriority  bool
	MaxSentences int
}

Config holds TTS configuration parameters.

type GeneratedAudio

type GeneratedAudio struct {
	Samples    []float32
	SampleRate int
}

GeneratedAudio holds synthesized audio data.

type OfflineTts

type OfflineTts struct {
	// contains filtered or unexported fields
}

OfflineTts wraps a sherpa-onnx offline TTS instance.

func NewOfflineTts

func NewOfflineTts(config Config, shared *SharedWeights) *OfflineTts

NewOfflineTts creates a TTS instance. If shared is non-nil, model weights are shared with other instances using the same SharedWeights.

func (*OfflineTts) Delete

func (t *OfflineTts) Delete()

Delete frees the TTS instance.

func (*OfflineTts) Generate

func (t *OfflineTts) Generate(text string, voiceID int, speed float32) *GeneratedAudio

Generate synthesizes speech from text.

type SharedWeights

type SharedWeights struct {
	// contains filtered or unexported fields
}

SharedWeights holds model data loaded once for sharing between TTS instances.

func NewSharedWeights

func NewSharedWeights(modelPath, voicesPath string) *SharedWeights

NewSharedWeights loads model.onnx and voices.bin into memory for sharing.

func (*SharedWeights) Delete

func (sw *SharedWeights) Delete()

Delete frees the shared weights.

Jump to

Keyboard shortcuts

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