-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtts_kokoro.rs
28 lines (26 loc) · 1.01 KB
/
tts_kokoro.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/kokoro-en-v0_19.tar.bz2
tar xf kokoro-en-v0_19.tar.bz2
rm kokoro-en-v0_19.tar.bz2
cargo run --example tts_kokoro
*/
pub use sherpa_rs::tts::{KokoroTts, KokoroTtsConfig};
fn main() {
let config = KokoroTtsConfig {
model: "./kokoro-en-v0_19/model.onnx".to_string(),
voices: "./kokoro-en-v0_19/voices.bin".into(),
tokens: "./kokoro-en-v0_19/tokens.txt".into(),
data_dir: "./kokoro-en-v0_19/espeak-ng-data".into(),
length_scale: 1.0,
..Default::default()
};
let mut tts = KokoroTts::new(config);
// 0->af, 1->af_bella, 2->af_nicole, 3->af_sarah, 4->af_sky, 5->am_adam
// 6->am_michael, 7->bf_emma, 8->bf_isabella, 9->bm_george, 10->bm_lewis
let sid = 0;
let audio = tts
.create("Hello! This audio generated by Kokoro!", sid, 1.0)
.unwrap();
sherpa_rs::write_audio_file("audio.wav", &audio.samples, audio.sample_rate).unwrap();
println!("Created audio.wav")
}