-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Kokoro English TTS model and update example usage #73
Conversation
Are there more logs? |
It crash in the let tts_config = sherpa_rs_sys::SherpaOnnxOfflineTtsConfig {
max_num_sentences: 0,
model: sherpa_rs_sys::SherpaOnnxOfflineTtsModelConfig {
kokoro: sherpa_rs_sys::SherpaOnnxOfflineTtsKokoroModelConfig {
model: model.as_ptr(),
voices: voices.as_ptr(),
tokens: tokens.as_ptr(),
data_dir: data_dir.as_ptr(),
length_scale: 1.0,
},
matcha: sherpa_rs_sys::SherpaOnnxOfflineTtsMatchaModelConfig {
acoustic_model: null(),
vocoder: null(),
lexicon: null(),
tokens: null(),
data_dir: null(),
noise_scale: 0.0,
length_scale: 0.0,
dict_dir: null(),
},
vits: sherpa_rs_sys::SherpaOnnxOfflineTtsVitsModelConfig {
data_dir: null(),
dict_dir: null(),
length_scale: 0.0,
lexicon: null(),
model: null(),
noise_scale: 0.0,
noise_scale_w: 0.0,
tokens: null(),
},
num_threads: config.num_threads.unwrap_or(2),
debug: 1,
provider: provider.as_ptr(),
},
rule_fars: null(),
rule_fsts: null(),
};
let tts = unsafe { sherpa_rs_sys::SherpaOnnxCreateOfflineTts(&tts_config) }; |
Maybe related to the fact the my default provider is coreml. I think I'm going to set the provider to CPU always by default to prevent such hard to debug errors |
Works with cpu! (I think the issue was with coreml) cargo run --no-default-features --features="tts" --example tts --features="tts" -- \
--text 'Hello! this audio generated by kokoro!' --output audio.wav --tokens "./kokoro-en-v0_19/tokens.txt" --model "./kokoro-en-v0_19/model.onnx" --voices ./kokoro-en-v0_19/voices.bin --data-dir "./kokoro-en-v0_19/espeak-ng-data" --sid 1 --provider cpu |
Is memory layout of the rust tts config struct the same as c-api? |
Should be of course. I use bindgen that creates many Rust structs / functions that are identical to sherpa-onnx. Note to myself: let matcha_config = unsafe { std::mem::zeroed::<sherpa_rs_sys::SherpaOnnxOfflineTtsMatchaModelConfig>() }; |
Add kokoro and update sherpa-onnx
TODO:
tts.rs
some_field: unsafe { std::mem::zerod }
instead of filling bunch of fields each time.