tts

package
v1.833.13 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlibabacloudTextToSpeechProvider

type AlibabacloudTextToSpeechProvider struct {
	// contains filtered or unexported fields
}

func NewAlibabacloudTextToSpeechProvider

func NewAlibabacloudTextToSpeechProvider(typ string, subType string, secretKey string, voice string) (*AlibabacloudTextToSpeechProvider, error)

func (*AlibabacloudTextToSpeechProvider) GetPricing

func (p *AlibabacloudTextToSpeechProvider) GetPricing() string

func (*AlibabacloudTextToSpeechProvider) QueryAudio

func (*AlibabacloudTextToSpeechProvider) QueryAudioStream

func (p *AlibabacloudTextToSpeechProvider) QueryAudioStream(text string, ctx context.Context, writer io.Writer, lang string) (*TextToSpeechResult, error)

type OpenAITextToSpeechProvider added in v1.832.38

type OpenAITextToSpeechProvider struct {
	// contains filtered or unexported fields
}

OpenAITextToSpeechProvider forwards to any OpenAI-compatible /v1/audio/speech endpoint — OpenAI itself, the in-cluster speech service, or a BYO node. It is the exact mirror of stt.OpenAISpeechToTextProvider: providerUrl is the OpenAI-compatible /v1 root (mirroring AIBaseURL's convention) and the provider appends the path; subType is the upstream model (kokoro family); voice, when set, is the requested voice, carried on the provider row's Flavor.

func NewOpenAITextToSpeechProvider added in v1.832.38

func NewOpenAITextToSpeechProvider(subType string, clientSecret string, providerUrl string, voice string, format string) (*OpenAITextToSpeechProvider, error)

func (*OpenAITextToSpeechProvider) GetPricing added in v1.832.38

func (p *OpenAITextToSpeechProvider) GetPricing() string

func (*OpenAITextToSpeechProvider) QueryAudio added in v1.832.38

func (p *OpenAITextToSpeechProvider) QueryAudio(text string, ctx context.Context, lang string) ([]byte, *TextToSpeechResult, error)

QueryAudio posts the text as an OpenAI speech request and returns the synthesized audio bytes. lang is the caller's UI language (error localization elsewhere); the synthesis voice is p.voice.

func (*OpenAITextToSpeechProvider) QueryAudioStream added in v1.832.38

func (p *OpenAITextToSpeechProvider) QueryAudioStream(text string, ctx context.Context, writer io.Writer, lang string) (*TextToSpeechResult, error)

QueryAudioStream writes the synthesized audio to writer. The OpenAI speech shape answers with one complete body rather than a chunked stream, so the bytes are synthesized and then written — the same result the streaming callers consume, without claiming an upstream stream that does not exist.

type TextToSpeechProvider

type TextToSpeechProvider interface {
	GetPricing() string
	QueryAudio(text string, ctx context.Context, lang string) ([]byte, *TextToSpeechResult, error)
	QueryAudioStream(text string, ctx context.Context, writer io.Writer, lang string) (*TextToSpeechResult, error)
}

func GetTextToSpeechProvider

func GetTextToSpeechProvider(typ string, subType string, clientId string, clientSecret string, providerUrl string, apiVersion string, pricePerThousandChars float64, currency string, flavor string, format string, lang string) (TextToSpeechProvider, error)

GetTextToSpeechProvider creates a new provider instance based on the provider type. flavor mirrors the STT factory's parameter: for TTS it is the synthesis voice, bound onto the provider row by the caller. format is the requested container (mp3, wav, …); it is forwarded to upstreams that honour it, and what comes back is reported on the result rather than assumed.

type TextToSpeechResult

type TextToSpeechResult struct {
	TokenCount int
	Price      float64
	Currency   string

	// ContentType is the media type the provider ACTUALLY produced, which is not
	// always the one the caller asked for: an upstream may ignore an unsupported
	// response_format and answer in its default. Reporting it lets the handler
	// label the bytes with what they are instead of with what was requested —
	// /v1/audio/speech used to answer `Content-Type: audio/opus` carrying MP3,
	// which is the API lying to a player. Empty means the provider did not say.
	ContentType string
}

Jump to

Keyboard shortcuts

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