Documentation
¶
Index ¶
- func NewSpeechRequestOptions(body io.ReadCloser) mo.Result[SpeechRequestOptions]
- func NewSpeechStreamStartOptions(payload []byte) mo.Result[SpeechRequestOptions]
- func NewVoicesRequestOptions(request *http.Request) mo.Result[VoicesRequestOptions]
- type ListVoicesResponse
- type OpenAISpeechRequestOptions
- type SpeechRequestOptions
- type SpeechStreamClientEvent
- type SpeechStreamClientEventType
- type SpeechStreamServerEvent
- type SpeechStreamServerEventType
- type Voice
- type VoiceCommonLabels
- type VoiceFormat
- type VoiceLabelKey
- type VoiceLanguage
- type VoicesRequestOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSpeechRequestOptions ¶
func NewSpeechRequestOptions(body io.ReadCloser) mo.Result[SpeechRequestOptions]
func NewSpeechStreamStartOptions ¶ added in v0.1.14
func NewSpeechStreamStartOptions(payload []byte) mo.Result[SpeechRequestOptions]
NewSpeechStreamStartOptions parses the WS `start` frame. Unlike NewSpeechRequestOptions, `input` is optional because text flows through later `text` frames.
func NewVoicesRequestOptions ¶ added in v0.1.0
func NewVoicesRequestOptions(request *http.Request) mo.Result[VoicesRequestOptions]
Types ¶
type ListVoicesResponse ¶ added in v0.1.0
type ListVoicesResponse struct {
Voices []Voice `json:"voices"`
}
type OpenAISpeechRequestOptions ¶
type OpenAISpeechRequestOptions struct {
// (required) One of the available TTS models.
Model string `json:"model"`
// (required) The text to generate audio for.
Input string `json:"input"`
// (required) The voice to use when generating the audio.
Voice string `json:"voice"`
// The format to audio in.
// Supported formats are mp3, opus, aac, flac, wav, and pcm.
// mp3 is the default.
ResponseFormat string `json:"response_format,omitempty"`
// The speed of the generated audio.
// Select a value from 0.25 to 4.0.
// 1.0 is the default.
Speed int `json:"speed,omitempty"`
// Extension: allows you to add custom content to body.
ExtraBody map[string]any `json:"extra_body,omitempty"`
}
OpenAISpeechRequestOptions represent API parameters refer to https://platform.openai.com/docs/api-reference/audio/createSpeech
type SpeechRequestOptions ¶
type SpeechRequestOptions struct {
OpenAISpeechRequestOptions
Backend string `json:"backend"`
Model string `json:"model"`
// contains filtered or unexported fields
}
func (SpeechRequestOptions) AsBuffer ¶
func (o SpeechRequestOptions) AsBuffer() mo.Option[*bytes.Buffer]
func (SpeechRequestOptions) AsMap ¶
func (o SpeechRequestOptions) AsMap() map[string]any
type SpeechStreamClientEvent ¶ added in v0.1.14
type SpeechStreamClientEvent struct {
Event SpeechStreamClientEventType `json:"event"`
Text string `json:"text,omitempty"`
}
type SpeechStreamClientEventType ¶ added in v0.1.14
type SpeechStreamClientEventType string
SpeechStreamClientEventType is the discriminator for events the client sends to unspeech on a streaming TTS WebSocket (JSON text frames).
const ( SpeechStreamClientEventStart SpeechStreamClientEventType = "start" SpeechStreamClientEventText SpeechStreamClientEventType = "text" SpeechStreamClientEventFinish SpeechStreamClientEventType = "finish" SpeechStreamClientEventCancel SpeechStreamClientEventType = "cancel" )
type SpeechStreamServerEvent ¶ added in v0.1.14
type SpeechStreamServerEventType ¶ added in v0.1.14
type SpeechStreamServerEventType string
SpeechStreamServerEventType is the discriminator for events unspeech sends back to the client (JSON text frames). Audio bytes travel as binary frames and do not use this envelope.
const ( SpeechStreamServerEventSessionStarted SpeechStreamServerEventType = "session.started" SpeechStreamServerEventSentenceStart SpeechStreamServerEventType = "sentence.start" SpeechStreamServerEventSentenceEnd SpeechStreamServerEventType = "sentence.end" SpeechStreamServerEventSubtitle SpeechStreamServerEventType = "subtitle" SpeechStreamServerEventSessionFinished SpeechStreamServerEventType = "session.finished" SpeechStreamServerEventError SpeechStreamServerEventType = "error" )
type Voice ¶ added in v0.1.0
type Voice struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Labels map[string]any `json:"labels"`
Tags []string `json:"tags"`
Languages []VoiceLanguage `json:"languages"`
Formats []VoiceFormat `json:"formats"`
CompatibleModels []string `json:"compatible_models"`
PredefinedOptions map[string]any `json:"predefined_options"`
PreviewAudioURL string `json:"preview_audio_url"`
}
type VoiceCommonLabels ¶ added in v0.1.0
type VoiceFormat ¶ added in v0.1.0
type VoiceLabelKey ¶ added in v0.1.0
type VoiceLabelKey = string
const ( VoiceLabelKeyAge VoiceLabelKey = "age" VoiceLabelKeyGender VoiceLabelKey = "gender" VoiceLabelKeyAccent VoiceLabelKey = "accent" VoiceLabelKeyType VoiceLabelKey = "type" )
type VoiceLanguage ¶ added in v0.1.0
type VoicesRequestOptions ¶ added in v0.1.0
Click to show internal directories.
Click to hide internal directories.