asyncai

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: BSD-2-Clause Imports: 24 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

Overview

Package asyncai is a streaming text-to-speech service backed by Async's TTS WebSocket. It holds one connection open for the call: the session is opened with an init message when the pipeline starts, each sentence is sent on the context it belongs to, and the raw PCM audio streams back on that context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// APIKey is the Async API key. Required.
	APIKey string `validate:"required"`
	// Voice is the voice id (UUID) to synthesize with. Required.
	Voice string `validate:"required"`
	// URL overrides the TTS WebSocket endpoint; empty uses the hosted endpoint.
	URL string
	// Version sets the API version; empty uses a default.
	Version string
	// Model is the Async model id; empty uses a default.
	Model string
	// Language is the synthesis language code; empty uses "en".
	Language string
	// SampleRate is the PCM rate requested and emitted downstream; 0 uses 24 kHz.
	SampleRate int
	// Websocket configures the connection: whether and how it reconnects, and
	// how long it waits on a peer that has stopped answering.
	Websocket wsservice.Options
}

Config configures the Async TTS service.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the configuration is usable.

type HTTPTTSConfig added in v0.7.0

type HTTPTTSConfig struct {
	// APIKey is the Async API key. Required.
	APIKey string `validate:"required"`
	// Voice is the voice id (UUID) to synthesize with. Required.
	Voice string `validate:"required"`
	// URL overrides the HTTP API base; empty uses the hosted API.
	URL string
	// Version sets the API version; empty uses a default.
	Version string
	// Model is the Async model id; empty uses a default.
	Model string
	// Language for synthesis; the zero value leaves it unset. Mapped to Async's
	// language code.
	Language language.Language
	// SampleRate is the PCM rate requested and emitted downstream; 0 uses 24 kHz.
	SampleRate int
	// Encoding is the audio encoding; empty uses "pcm_s16le".
	Encoding string
	// Container is the audio container; empty uses "raw".
	Container string
	// Client makes the requests; nil uses a client of its own. The service
	// sends through a copy of it, so the client itself is left as it is.
	Client *http.Client
}

HTTPTTSConfig configures the Async HTTP TTS service.

func (HTTPTTSConfig) Validate added in v0.7.0

func (c HTTPTTSConfig) Validate() error

Validate reports whether the configuration is usable.

type HTTPTTSService added in v1.0.0

type HTTPTTSService struct {
	*tts.Base
}

HTTPTTSService is the Async text-to-speech service NewHTTPTTS builds.

func NewHTTPTTS added in v0.7.0

func NewHTTPTTS(cfg HTTPTTSConfig) *HTTPTTSService

NewHTTPTTS builds an Async TTS service over the HTTP streaming API. Each sentence is one request, whose audio is read whole and yielded as one frame. Prefer NewTTS on a call, where a connection held open spares each sentence the request.

type TTSService added in v1.0.0

type TTSService struct {
	*tts.Base
}

TTSService is the Async text-to-speech service NewTTS builds.

func NewTTS

func NewTTS(cfg Config) *TTSService

NewTTS builds an Async TTS service.

It holds one connection open for the call, opened when the pipeline starts. When it drops it is restored with backoff, and when that keeps failing the service reports a permanent error and becomes unusable. See tts.Websocket.

Jump to

Keyboard shortcuts

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