| Crates.io | elevenlabs_vc |
| lib.rs | elevenlabs_vc |
| version | 0.0.4 |
| created_at | 2025-08-30 02:05:51.094675+00 |
| updated_at | 2025-09-01 17:03:24.397702+00 |
| description | Type-safe Rust client for ElevenLabs Voice Changer API |
| homepage | |
| repository | https://github.com/hamzaelmarjani/elevenlabs_vc |
| max_upload_size | |
| id | 1817169 |
| size | 91,009 |
A type-safe, async Rust client for the ElevenLabs Voice Changer API. Transform audio from one voice to another. Maintain full control over emotion, timing and delivery, with simple Ergonomic API.
voices::all_voices::*)models::elevenlabs_models::*)This project is part of a milestone to implement all ElevenLabs APIs in Rust.
Add this to your Cargo.toml:
[dependencies]
elevenlabs_vc = "0.0.4"
use elevenlabs_vc::{ElevenLabsVCClient, voices};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ElevenLabsVCClient::new("your-api-key");
let file_path = "inputs/speech.mp3";
let file_content = std::fs::read(file_path)?;
let audio = client.voice_changer([].to_vec(), voices::all_voices::PAUL.voice_id).execute().await?;
std::fs::write("output.mp3", &audio)?;
Ok(())
}
use elevenlabs_vc::{ElevenLabsVCClient, voices};
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key =
env::var("ELEVENLABS_API_KEY").expect("Please set ELEVENLABS_API_KEY environment variable");
let client = ElevenLabsVCClient::new(api_key);
let file_path = "inputs/input.mp3";
let file_content = std::fs::read(file_path)?;
let audio = client
.voice_changer(file_content, voices::all_voices::PAUL.voice_id)
.execute()
.await?;
std::fs::create_dir_all("outputs")?;
let audio_id = chrono::Utc::now().timestamp();
let file_name = format!("outputs/{}.mp3", audio_id);
std::fs::write(file_name.clone(), &audio)?;
Ok(())
}
use elevenlabs_vc::{ElevenLabsVCClient, VoiceSettings, models, voices};
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key =
env::var("ELEVENLABS_API_KEY").expect("Please set ELEVENLABS_API_KEY environment variable");
let client = ElevenLabsVCClient::new(api_key);
let file_path = "inputs/input.mp3";
let file_content = std::fs::read(file_path)?;
let audio = client
.voice_changer(file_content, voices::all_voices::PAUL.voice_id)
.model(models::elevanlabs_models::ELEVEN_MULTILINGUAL_STS_V2)
.remove_background_noise(true)
.seed(2500)
.voice_settings(
VoiceSettings::default()
.stability(0.5)
.speaker_boost(true)
.similarity_boost(0.7)
.speed(0.97),
)
.execute()
.await?;
std::fs::create_dir_all("outputs")?;
let audio_id = chrono::Utc::now().timestamp();
let file_name = format!("outputs/{}.mp3", audio_id);
std::fs::write(file_name.clone(), &audio)?;
Ok(())
}
# Set your API key
export ELEVENLABS_API_KEY=your_api_key_here
# Run the basic example
cargo run --example basic_vc
# Run the advanced example
cargo run --example advanced_vc
| Method | Description |
|---|---|
ElevenLabsVCClient::new(Vec<u8>, String) |
Create client instance, requires audio (Vec |
.output_format(String) |
Output format of the changed voice audio (optional) |
.model_id(String) |
Identifier of the model that will be used (optional) |
.voice_settings(VoiceSettings) |
Voice settings overriding stored settings for the given voice (optional) |
.seed(u32) |
Our system will make a best effort to sample deterministically (optional) |
.remove_background_noise(bool) |
Remove the background noise from your audio input (optional) |
.file_format(String) |
The format of input audio (optional) |
.execute() |
Run request → change audio voice (required)* |
The crate uses standard Rust error handling patterns. All async methods return Result types:
match client.voice_changer(audio, voice_id).execute().await {
Ok(output) => println!("Audio changed voice: {}", output.len()),
Err(e) => eprintln!("VC request failed: {}", e),
}
Licensed under either of:
at your option.
Contributions are welcome! Please feel free to:
Before contributing, please ensure your code follows Rust conventions and includes appropriate tests.
If you like this project, consider supporting me on Patreon 💖
See CHANGELOG.md for a detailed history of changes.
Note: This crate is not officially affiliated with ElevenLabs. Please refer to the ElevenLabs API documentation for the most up-to-date API information.