Documentation
¶
Overview ¶
Package tts provides text-to-speech synthesis for DevClaw. Supports multiple providers: OpenAI TTS (paid, high quality), Edge TTS (free, Microsoft Azure voices), and auto-fallback.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EdgeProvider ¶
type EdgeProvider struct {
// contains filtered or unexported fields
}
EdgeProvider implements TTS via Microsoft Edge's speech synthesis service. Uses the same underlying Azure Cognitive Services as the edge-tts Python package, but via direct HTTP calls — no external dependencies needed.
Popular voices:
- pt-BR-FranciscaNeural (Brazilian Portuguese, female)
- pt-BR-AntonioNeural (Brazilian Portuguese, male)
- en-US-JennyNeural (US English, female)
- en-US-GuyNeural (US English, male)
- es-ES-ElviraNeural (Spanish, female)
func NewEdgeProvider ¶
func NewEdgeProvider(logger *slog.Logger) *EdgeProvider
NewEdgeProvider creates an Edge TTS provider.
func (*EdgeProvider) Synthesize ¶
Synthesize converts text to audio using Microsoft Edge TTS. Returns audio in MP3 format.
type FallbackProvider ¶
type FallbackProvider struct {
// contains filtered or unexported fields
}
FallbackProvider tries the primary provider and falls back to the secondary if the primary fails. Useful for "auto" mode where OpenAI is preferred but Edge TTS is the free fallback.
func NewFallbackProvider ¶
func NewFallbackProvider(primary, secondary Provider, primaryVoice, secondaryVoice string, logger *slog.Logger) *FallbackProvider
NewFallbackProvider creates a provider that tries primary first, then secondary.
func (*FallbackProvider) Synthesize ¶
func (p *FallbackProvider) Synthesize(ctx context.Context, text, voice string) ([]byte, string, error)
Synthesize tries the primary provider, falling back to secondary on failure.
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider implements TTS via the OpenAI TTS API.
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey, baseURL, model string) *OpenAIProvider
NewOpenAIProvider creates an OpenAI TTS provider.
func (*OpenAIProvider) Synthesize ¶
func (p *OpenAIProvider) Synthesize(ctx context.Context, text, voice string) ([]byte, string, error)
Synthesize converts text to audio using the OpenAI TTS API. Returns audio in Opus format (ideal for voice notes on WhatsApp/Telegram).