Documentation
¶
Overview ¶
Package speechify provides Speechify text-to-speech over the HTTP API. Each sentence is one request to the /v1/audio/stream/with-timestamps endpoint, which streams the PCM audio and word-level speech marks back as server-sent events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPTTSConfig ¶
type HTTPTTSConfig struct {
// APIKey is the Speechify API key. Required.
APIKey string `validate:"required"`
// URL overrides the API base; empty uses "https://api.speechify.ai".
URL string
// SampleRate is the PCM rate emitted downstream; 0 uses 24 kHz. A rate
// Speechify does not render (it renders 8000, 16000, 22050, 24000, 44100
// and 48000) is synthesized at 24 kHz and resampled to this one.
SampleRate int
// Model is the Speechify model; empty uses "simba-3.5", which covers 48
// languages, English included. The legacy simba-english and
// simba-multilingual models are retired at the API version the service
// pins, and are refused.
Model string
// Voice is the voice id; empty uses "geffen_32".
Voice string
// Language for synthesis; the zero value leaves it to Speechify. Mapped to
// Speechify's language tag.
Language language.Language
// LoudnessNormalization normalizes the audio loudness to a standard level,
// at the cost of latency. Nil leaves it to Speechify.
LoudnessNormalization *bool
// TextNormalization spells out numbers, dates and similar tokens before
// synthesis, at the cost of latency. Nil leaves it to Speechify.
TextNormalization *bool
// SafetyIdentifier is a stable, opaque identifier for the end user a
// request is synthesized for, so Speechify can rate-limit or block that
// user instead of the whole workspace. 1 to 64 characters of letters,
// digits and ". _ - : | + / =": a keyed hash of an internal user id, never
// personal data such as an email address, which Speechify rejects. Empty
// sends none.
SafetyIdentifier string
// Pronunciations says how specific words in the text should be spoken, up
// to 200 entries. Each entry gives the "text" to match and exactly one of
// "ipa" (phones from the model's set, for a single word) or "alias"
// (replacement text), plus an optional "case_sensitive":
//
// []map[string]any{
// {"text": "jargo", "ipa": "dʒ ˈɑː ɹ ɡ oʊ"},
// {"text": "TTS", "alias": "text to speech"},
// }
//
// Speechify applies these on simba-3.5 in every language it lists under
// pronunciation_languages in GET /v1/audio/models, which excludes English;
// any other model or language is refused with pronunciations_unsupported.
// Text transforms on the service (see tts.Base.SetTextTransformers) are
// another way to guide pronunciation, applied before the text reaches the
// provider. Nil sends none.
Pronunciations []map[string]any
// TextAggregation is how streamed text is grouped before synthesis:
// frames.TextTypeSentence (the zero value) sends a sentence at a time,
// frames.TextTypeToken streams the tokens as they arrive.
TextAggregation frames.TextType
// Client makes the requests; nil uses a client of its own.
Client *http.Client
}
HTTPTTSConfig configures the Speechify HTTP TTS service.
func (HTTPTTSConfig) Validate ¶
func (c HTTPTTSConfig) Validate() error
Validate reports whether the configuration is usable.
type HTTPTTSService ¶ added in v1.0.0
HTTPTTSService is the Speechify text-to-speech service NewHTTPTTS builds.
func NewHTTPTTS ¶
func NewHTTPTTS(cfg HTTPTTSConfig) *HTTPTTSService
NewHTTPTTS builds a Speechify TTS service over the HTTP API. Each sentence is one request, whose audio and word-level speech marks stream back as server-sent events, so the conversation keeps only what was heard before an interruption.
Requests pin Speechify's API version rather than letting the workspace default decide it.
type TTSSettings ¶
type TTSSettings struct {
settings.TTS
// LoudnessNormalization normalizes the audio loudness to a standard level.
LoudnessNormalization settings.Opt[bool] `settings:"loudness_normalization"`
// TextNormalization spells out numbers, dates and similar tokens.
TextNormalization settings.Opt[bool] `settings:"text_normalization"`
// SafetyIdentifier identifies the end user a request is synthesized for.
SafetyIdentifier settings.Opt[string] `settings:"safety_identifier"`
// Pronunciations says how specific words in the text should be spoken.
Pronunciations settings.Opt[[]map[string]any] `settings:"pronunciations"`
}
TTSSettings is the Speechify configuration that can change while the pipeline runs, through a TTSUpdateSettingsFrame. Each request is built from it, so a change applies from the next sentence on.