Typecast Rust SDK
Official Rust SDK for the Typecast Text-to-Speech API.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Quick Start
use ;
async
Configuration
Environment Variables
TYPECAST_API_KEY: Your Typecast API key (required)TYPECAST_API_HOST: Custom API host (optional, defaults tohttps://api.typecast.ai)
Custom Configuration
use ;
use Duration;
let config = new
.base_url
.timeout;
let client = new?;
Features
Text-to-Speech
use ;
// Basic request
let request = new;
// With language and output settings
let request = new
.language
.output
.seed;
Emotion Control
Preset Emotions (ssfm-v30)
use ;
let request = new
.prompt;
Available presets:
Normal- Neutral, balanced toneHappy- Bright, cheerful expressionSad- Melancholic, subdued toneAngry- Strong, intense deliveryWhisper- Soft, quiet speech (ssfm-v30 only)ToneUp- Higher tonal emphasis (ssfm-v30 only)ToneDown- Lower tonal emphasis (ssfm-v30 only)
Smart Context-Aware Emotion (ssfm-v30)
use SmartPrompt;
let request = new
.prompt;
Voice Discovery
use ;
// Get all voices
let voices = client.get_voices_v2.await?;
// Filter voices
let filter = new
.model
.gender
.age;
let voices = client.get_voices_v2.await?;
// Get specific voice
let voice = client.get_voice_v2.await?;
println!;
Error Handling
use TypecastError;
match client.text_to_speech.await
Supported Languages
The API supports 37 languages with ssfm-v30 model:
| Code | Language | Code | Language | Code | Language |
|---|---|---|---|---|---|
| eng | English | kor | Korean | jpn | Japanese |
| zho | Chinese | spa | Spanish | fra | French |
| deu | German | ita | Italian | por | Portuguese |
| rus | Russian | ara | Arabic | hin | Hindi |
| ... and more |
Running Tests
# Set your API key
# Run all tests
# Run integration tests only
License
MIT License - see LICENSE for details.