tts

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultResponseFormat = "opus"

DefaultResponseFormat is the audio format channels request when Options do not name one: Ogg Opus, which Discord voice playback and chat voice messages need. A provider that cannot return it returns its own format, which the stream reports.

Variables

This section is empty.

Functions

func StreamAudioMeta

func StreamAudioMeta(stream io.Reader) (fileExt string, contentType string, ok bool)

StreamAudioMeta returns the file extension and content type of stream, audio a TTSProvider synthesized; ok is false when the provider does not say.

func SynthesizeAndStore

func SynthesizeAndStore(
	ctx context.Context,
	provider TTSProvider,
	store media.MediaStore,
	text string,
	filename string,
	channel string,
	chatID string,
) (string, error)

SynthesizeAndStore synthesizes text to speech and registers it in the media store, returning the media reference.

Types

type Options

type Options struct {
	// Voice is the synthesis voice; empty uses the provider's default.
	Voice string
	// ResponseFormat is the requested OpenAI response format, such as "opus"
	// or "mp3"; empty uses DefaultResponseFormat.
	ResponseFormat string
}

Options configure a TTSProvider.

type TTSProvider

type TTSProvider interface {
	Name() string
	Synthesize(ctx context.Context, text string) (io.ReadCloser, error)
}

func DetectTTS

func DetectTTS(cfg *config.Config) TTSProvider

DetectTTS returns the TTS provider of cfg's text-to-speech target, cfg.Voice.TTSTarget, speaking with cfg.Voice.TTSVoice. It returns nil, which turns speech synthesis off, when no target is configured or the target cannot synthesize speech.

func NewProvider

func NewProvider(client *voice.Client, options Options) TTSProvider

NewProvider returns the TTSProvider of a text-to-speech voice client.

Jump to

Keyboard shortcuts

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