Add support for listing voices See merge request ndarilek/speech-dispatcher-rs!2master
commit
0dc9205b36
@ -0,0 +1,29 @@
|
|||||||
|
use speech_dispatcher::*;
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let connection = Connection::open("list_voices", "list_voices", "list_voices", Mode::Threaded)?;
|
||||||
|
|
||||||
|
let modules = connection.list_output_modules()?;
|
||||||
|
println!("Modules available: {:?}", modules);
|
||||||
|
for module in modules.into_iter() {
|
||||||
|
if connection.set_output_module(&module).is_ok() {
|
||||||
|
println!("Listing voices for module {}", module);
|
||||||
|
} else {
|
||||||
|
println!("Failed to set output module to {}", module);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let voices = connection.list_synthesis_voices()?;
|
||||||
|
for voice in voices.into_iter() {
|
||||||
|
if let Some(variant) = voice.variant.as_deref() {
|
||||||
|
println!(
|
||||||
|
" Name: {} / Language: {} / Variant: {}",
|
||||||
|
voice.name, voice.language, variant
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
println!(" Name: {} / Language: {}", voice.name, voice.language);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use connection.set_synthesis_voice(voice.name) to set the voice to use.
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in new issue