Documentation
¶
Index ¶
- Constants
- func CheckTTSLoadError() (error, bool)
- func PreloadTTSModel(lg *log.Logger, uploadDone <-chan struct{}, targetSampleRate int)
- func SetPlaybackSpeed(speed float32)
- func SynthesizeContactTTS(text, voice string, radioSeed uint32) ([]int16, error)
- func SynthesizeReadbackTTS(text, voice string, radioSeed uint32) ([]int16, error)
- type Config
- type GeneratedAudio
- type OfflineTts
- type SharedWeights
Constants ¶
const DefaultPlaybackSpeed = 1.5
DefaultPlaybackSpeed is the Kokoro TTS speed multiplier used when no user preference is set. Chinese voices are scaled proportionally.
Variables ¶
This section is empty.
Functions ¶
func CheckTTSLoadError ¶
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 ¶
PreloadTTSModel kicks off background loading of the TTS model. If uploadDone is non-nil, the load goroutine blocks on it before doing any cgo work, so a recurring init-time crash can't kill us before the prior run's crash report is shipped to the server.
func SetPlaybackSpeed ¶ added in v0.14.6
func SetPlaybackSpeed(speed float32)
SetPlaybackSpeed sets the base TTS speed multiplier used for synthesis. Chinese voices use a proportionally slower speed.
func SynthesizeContactTTS ¶
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 ¶
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 ¶
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) 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.