AllTalk Client
A Rust client library for the AllTalk Text-to-Speech (TTS) API. This library provides a convenient way to interact with AllTalk's TTS services from Rust applications.
Features
- 🎙️ Text-to-Speech Generation: Convert text to speech using various voice models
- 🔄 Model Management: Switch between different TTS models (API TTS, API Local, XTTSv2 Local, XTTSv2 FT)
- 🎚️ Advanced Settings: Control DeepSpeed, Low VRAM mode, and other performance settings
- 🌐 Multi-language Support: Support for 17 languages including English, Spanish, French, German, and more
- 👥 Voice Management: List available voices and preview voice samples
- 🎭 Narrator Support: Separate character and narrator voice generation
- 📁 File Download: Download generated audio files directly
- 🔍 Health Checks: Check if the TTS service is ready
- ⚡ Async/Await: Fully asynchronous API using tokio
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
async
Configuration
Environment Variables
ALLTALK_URL: The base URL of your AllTalk server (e.g.,http://127.0.0.1:7851)
Client Creation
use AllTalkClient;
use Url;
// From environment variable
let client = from_environment?;
// From explicit URL
let url = parse?;
let client = from_url?;
API Reference
Core Methods
Health Check
// Check if the TTS service is ready
let is_ready = client.is_ready.await?;
Voice Management
// Get list of available voices
let voices = client.get_voices.await?;
// Preview a voice with sample text
let preview_url = client.preview_voice.await?;
Settings and Configuration
// Get current settings
let settings = client.get_current_settings.await?;
// Switch TTS model
client.switch_model.await?;
// Toggle DeepSpeed
client.switch_deepspeed.await?;
// Toggle Low VRAM mode
client.switch_low_vram_setting.await?;
Text-to-Speech Generation
Basic Generation
use ;
let options = TTSModelOptions ;
let response = client.generate_tts.await?;
Advanced Generation with Narrator
let options = TTSModelOptions ;
let response = client.generate_tts.await?;
File Download
// Download generated audio file
client.download_file.await?;
Supported Languages
| Language | Code |
|---|---|
| Arabic | ar |
| Chinese (Simplified) | zh-cn |
| Czech | cs |
| Dutch | nl |
| English | en |
| French | fr |
| German | de |
| Hindi | hi |
| Hungarian | hu |
| Italian | it |
| Japanese | ja |
| Korean | ko |
| Polish | pl |
| Portuguese | pt |
| Russian | ru |
| Spanish | es |
| Turkish | tr |
Text Filtering Options
- None: No filtering, raw text passed to TTS engine
- Standard: Basic filtering for human-readable text
- HTML: Handles HTML entities and content
TTS Models
The client supports switching between different TTS models:
- API TTS: Cloud-based TTS service
- API Local: Local API-based TTS
- XTTSv2 Local: Local XTTSv2 model
- XTTSv2 FT: Fine-tuned XTTSv2 model (requires trained model in
/models/trainedmodel/)
Error Handling
The library uses the AllTalkError enum for error handling:
use AllTalkError;
match client.generate_tts.await
Examples
Complete Example with Voice Preview
use ;
async
Dependencies
- reqwest: HTTP client for API requests
- tokio: Async runtime
- serde: JSON serialization/deserialization
- url: URL parsing and manipulation
- anyhow: Error handling utilities
- thiserror: Custom error types
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Related Projects
- AllTalk TTS - The main AllTalk Text-to-Speech project
Author
Alberto Paro alberto.paro@gmail.com