tts

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 10 Imported by: 0

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

func (p *EdgeProvider) Synthesize(ctx context.Context, text, voice string) ([]byte, string, error)

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).

type Provider

type Provider interface {
	// Synthesize converts text to audio.
	// Returns audio bytes, MIME type (e.g. "audio/ogg"), and error.
	Synthesize(ctx context.Context, text, voice string) ([]byte, string, error)
}

Provider is the interface for TTS backends.

Jump to

Keyboard shortcuts

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