gradium

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package gradium provides Gradium's speech services: streaming text-to-speech and real-time streaming speech-to-text, both over Gradium's WebSocket API. The TTS side opens a session per sentence, sends the transcript, and streams the raw PCM audio chunks downstream; the STT side streams 80 ms audio chunks and surfaces recognized text as interim and finalized transcriptions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSTT

func NewSTT(cfg STTConfig) *stt.StreamService

NewSTT builds a Gradium streaming STT service.

func NewTTS

func NewTTS(cfg TTSConfig) *tts.Base

NewTTS builds a Gradium TTS service.

Types

type STTConfig

type STTConfig struct {
	// APIKey is the Gradium API key, sent as the x-api-key header. Required.
	APIKey string `validate:"required"`
	// URL overrides the ASR WebSocket endpoint; empty uses the hosted endpoint.
	URL string
	// Model is the transcription model; empty uses a default.
	Model string
	// Encoding is the base audio encoding ("pcm", "wav", or "opus"); empty uses
	// "pcm". For PCM the sample rate is appended to form the input format (for
	// example "pcm_16000").
	Encoding string
	// Language hints the spoken language; the zero value lets the server decide.
	// Verified codes are de, en, es, fr, and pt; other languages fall back to
	// the base code.
	Language language.Language
	// SampleRate is the input audio sample rate; 0 uses the transport's rate.
	SampleRate int
	// DelayInFrames delays text generation by this many 80 ms frames; nil uses a
	// default. Allowed values: 7, 8, 10, 12, 14, 16, 20, 24, 36, 48.
	DelayInFrames *int `validate:"omitempty,oneof=7 8 10 12 14 16 20 24 36 48"`
}

STTConfig configures the Gradium STT service.

func (STTConfig) Validate

func (c STTConfig) Validate() error

Validate reports whether the configuration is usable.

type TTSConfig

type TTSConfig struct {
	// APIKey is the Gradium API key, sent as the x-api-key header. Required.
	APIKey string `validate:"required"`
	// URL overrides the TTS WebSocket endpoint; empty uses the hosted endpoint.
	URL string
	// VoiceID is the voice identifier; empty uses a default voice.
	VoiceID string
	// JSONConfig is an optional JSON configuration string forwarded to the model;
	// empty omits it.
	JSONConfig string
}

TTSConfig configures the Gradium TTS service.

func (TTSConfig) Validate

func (c TTSConfig) Validate() error

Validate reports whether the configuration is usable.

Jump to

Keyboard shortcuts

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