Help us shape the future of Go! Take the 2026 Go Developer Survey

tts

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package tts provides a provider-agnostic interface for text-to-speech synthesis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generation

type Generation interface {
	// GenerateAudio synthesises speech from the provided text.
	GenerateAudio(ctx context.Context, text string) (*Response, error)
	// ListVoices returns voices available from this provider.
	ListVoices(ctx context.Context) ([]Voice, error)
	// Provider returns a stable provider name (e.g. "openai", "elevenlabs").
	Provider() string
}

Generation is the core interface for text-to-speech providers. Implementations must be safe for concurrent use.

type Response

type Response struct {
	// AudioData is the raw audio bytes in the format specified by ContentType.
	AudioData []byte
	// ContentType is the MIME type (e.g. "audio/mpeg", "audio/wav").
	ContentType string
	// Model is the model/voice-engine that produced the audio.
	Model string
	// CharactersUsed is the number of input characters consumed (for billing).
	CharactersUsed int
}

Response holds the synthesised audio from a single GenerateAudio call.

type Voice

type Voice struct {
	// ID is the provider-internal voice identifier (e.g. "alloy", "nova").
	ID string
	// Name is a human-readable label.
	Name string
	// Language is an IETF language tag (e.g. "en-US").
	Language string
	// Description is an optional short description of the voice character.
	Description string
}

Voice describes a speaker voice offered by a provider.

Jump to

Keyboard shortcuts

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