Documentation
¶
Overview ¶
Package tts exposes the embeddable SpeechKit text-to-speech surface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMissingRouter = errors.New("speechkit tts: router is required")
Functions ¶
func PreferredProviderForProfileID ¶
PreferredProviderForProfileID maps a Voice-Output profile ID to Provider.Name.
Types ¶
type Provider ¶
type Provider interface {
Synthesize(ctx context.Context, text string, opts SynthesizeOpts) (*Result, error)
Name() string
Kind() ProviderKind
Health(ctx context.Context) error
}
Provider defines the interface for text-to-speech backends.
func OrderByPreferredProvider ¶
OrderByPreferredProvider returns providers with the matching provider first.
type ProviderKind ¶
type ProviderKind string
ProviderKind identifies whether a provider is local, cloud-routed, or a direct external API. Router strategies use this instead of provider names.
const ( ProviderKindLocalBuiltIn ProviderKind = "local_built_in" ProviderKindLocalProvider ProviderKind = "local_provider" ProviderKindCloudProvider ProviderKind = "cloud_provider" ProviderKindDirectProvider ProviderKind = "direct_provider" )
type Result ¶
type Result struct {
Audio []byte
Format string
SampleRate int
Duration time.Duration
Provider string
Voice string
}
Result holds the output of a TTS synthesis.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router selects and falls back between TTS providers.
func (*Router) CloseIdleConnections ¶
func (r *Router) CloseIdleConnections()
CloseIdleConnections asks HTTP-backed providers to drop idle connection pools.
func (*Router) HealthCheck ¶
HealthCheck returns health status for all providers.
func (*Router) SetProviders ¶
SetProviders replaces the provider list.
func (*Router) Synthesize ¶
Synthesize tries each eligible provider until one succeeds.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a small stable facade over Router. It gives embedders one construction point while still letting them provide their own providers.
func NewService ¶
func NewService(router *Router, opts ...ServiceOption) (*Service, error)
func (*Service) Synthesize ¶
type ServiceOption ¶
type ServiceOption func(*Service)
func WithDefaultOpts ¶
func WithDefaultOpts(opts SynthesizeOpts) ServiceOption