8 releases
Uses new Rust 2024
| new 0.1.7 | Feb 23, 2026 |
|---|---|
| 0.1.6 | Jan 7, 2026 |
| 0.1.5 | Dec 30, 2025 |
| 0.1.0 | Nov 20, 2025 |
#623 in Audio
71KB
980 lines
Gradium
This repo contains a Rust client for the Gradium Voice AI API.
cargo run -r --example tts -- \
--text "Hello, this is a test of the gradium text-to-speech system. Please ensure that you follow the signs." \
--out-file ~/tmp/out.wav \
lib.rs:
Gradium Rust Client
A Rust client library for the Gradium API, providing text-to-speech (TTS) capabilities via WebSocket connections.
Quick Start
use gradium::{Client, protocol::tts::Setup, protocol::AudioFormat};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let api_key = gradium::api_key_from_env().expect("GRADIUM_API_KEY not set");
let client = Client::new(&api_key);
let setup = Setup::new("m86j6D7UZpGzHsNu").with_output_format(AudioFormat::Wav);
let result = gradium::tts("Hello, world!", setup, &client).await?;
let filename = "output.wav";
std::fs::write(filename, result.raw_data())?;
println!("Generated {} bytes of audio and saved to {}", result.raw_data().len(), filename);
Ok(())
}
Features
- Simple API: High-level
tts()function for one-shot text-to-speech conversion - Streaming Support:
TtsStreamfor advanced use cases with real-time audio streaming - Multiple Formats: Support for PCM, WAV, and Opus audio formats
- Async/Await: Built on tokio for efficient async I/O
Environment Configuration
The client expects the GRADIUM_API_KEY environment variable to be set with your API key.
You can retrieve it using the [api_key_from_env()] function.
Dependencies
~7–26MB
~340K SLoC