tts

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTextTransforms

func ApplyTextTransforms(text string) string

func FilterEmoji

func FilterEmoji(text string) string

func FilterMarkdown

func FilterMarkdown(text string) string

Types

type ChunkedStream

type ChunkedStream interface {
	Next() (*SynthesizedAudio, error)
	Close() error
}

type FallbackAdapter

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

func NewFallbackAdapter

func NewFallbackAdapter(ttss []TTS) *FallbackAdapter

func (*FallbackAdapter) Capabilities

func (f *FallbackAdapter) Capabilities() TTSCapabilities

func (*FallbackAdapter) Label

func (f *FallbackAdapter) Label() string

func (*FallbackAdapter) NumChannels

func (f *FallbackAdapter) NumChannels() int

func (*FallbackAdapter) SampleRate

func (f *FallbackAdapter) SampleRate() int

func (*FallbackAdapter) Stream

func (*FallbackAdapter) Synthesize

func (f *FallbackAdapter) Synthesize(ctx context.Context, text string) (ChunkedStream, error)

type SentenceStreamPacer

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

SentenceStreamPacer buffers text from the LLM, groups it into sentences, and only forwards sentences to the underlying TTS stream when the synthesized audio buffer falls below a certain duration threshold. This prevents runaway TTS generation costs if the user interrupts early.

func NewSentenceStreamPacer

func NewSentenceStreamPacer(ctx context.Context, underlying SynthesizeStream, minRemainingAudio time.Duration) *SentenceStreamPacer

func (*SentenceStreamPacer) Close

func (p *SentenceStreamPacer) Close() error

func (*SentenceStreamPacer) Flush

func (p *SentenceStreamPacer) Flush() error

func (*SentenceStreamPacer) Next

func (*SentenceStreamPacer) PushText

func (p *SentenceStreamPacer) PushText(text string) error

type StreamAdapter

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

func NewStreamAdapter

func NewStreamAdapter(t TTS) *StreamAdapter

func (*StreamAdapter) Capabilities

func (a *StreamAdapter) Capabilities() TTSCapabilities

func (*StreamAdapter) Label

func (a *StreamAdapter) Label() string

func (*StreamAdapter) NumChannels

func (a *StreamAdapter) NumChannels() int

func (*StreamAdapter) SampleRate

func (a *StreamAdapter) SampleRate() int

func (*StreamAdapter) Stream

func (*StreamAdapter) Synthesize

func (a *StreamAdapter) Synthesize(ctx context.Context, text string) (ChunkedStream, error)

type SynthesizeStream

type SynthesizeStream interface {
	PushText(text string) error
	Flush() error
	Close() error
	Next() (*SynthesizedAudio, error)
}

type SynthesizedAudio

type SynthesizedAudio struct {
	Frame     *model.AudioFrame
	RequestID string
	IsFinal   bool
	SegmentID string
	DeltaText string
}

type TTS

type TTS interface {
	Label() string
	Capabilities() TTSCapabilities
	SampleRate() int
	NumChannels() int
	Synthesize(ctx context.Context, text string) (ChunkedStream, error)
	Stream(ctx context.Context) (SynthesizeStream, error)
}

type TTSCapabilities

type TTSCapabilities struct {
	Streaming         bool
	AlignedTranscript bool
}

Jump to

Keyboard shortcuts

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