types

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

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 SpeechStreamServerEvent struct {
	Event   SpeechStreamServerEventType `json:"event"`
	Text    string                      `json:"text,omitempty"`
	Code    string                      `json:"code,omitempty"`
	Message string                      `json:"message,omitempty"`
	Payload map[string]any              `json:"payload,omitempty"`
}

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 VoiceCommonLabels struct {
	Gender       string `json:"gender"`
	Language     string `json:"language"`
	LanguageCode string `json:"language_code"`
	SampleRate   int    `json:"sample_rate"`
}

type VoiceFormat added in v0.1.0

type VoiceFormat struct {
	Name       string `json:"name"`
	Extension  string `json:"extension"`
	MimeType   string `json:"mime_type"`
	SampleRate int    `json:"sample_rate,omitempty"`
	Bitrate    int    `json:"bitrate,omitempty"`
	FormatCode string `json:"format_code,omitempty"` // For provider-specific format codes
}

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 VoiceLanguage struct {
	Title string `json:"title"`
	Code  string `json:"code"`
}

type VoicesRequestOptions added in v0.1.0

type VoicesRequestOptions struct {
	Backend string `json:"provider"`

	ExtraQuery url.Values `json:"extra_query"`
}

Jump to

Keyboard shortcuts

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