Documentation
¶
Index ¶
- type AlibabacloudTextToSpeechProvider
- func (p *AlibabacloudTextToSpeechProvider) GetPricing() string
- func (p *AlibabacloudTextToSpeechProvider) QueryAudio(text string, ctx context.Context, lang string) ([]byte, *TextToSpeechResult, error)
- func (p *AlibabacloudTextToSpeechProvider) QueryAudioStream(text string, ctx context.Context, writer io.Writer, lang string) (*TextToSpeechResult, error)
- type OpenAITextToSpeechProvider
- func (p *OpenAITextToSpeechProvider) GetPricing() string
- func (p *OpenAITextToSpeechProvider) QueryAudio(text string, ctx context.Context, lang string) ([]byte, *TextToSpeechResult, error)
- func (p *OpenAITextToSpeechProvider) QueryAudioStream(text string, ctx context.Context, writer io.Writer, lang string) (*TextToSpeechResult, error)
- type TextToSpeechProvider
- type TextToSpeechResult
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 (*AlibabacloudTextToSpeechProvider) GetPricing ¶
func (p *AlibabacloudTextToSpeechProvider) GetPricing() string
func (*AlibabacloudTextToSpeechProvider) QueryAudio ¶
func (p *AlibabacloudTextToSpeechProvider) QueryAudio(text string, ctx context.Context, lang string) ([]byte, *TextToSpeechResult, error)
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 (*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
}