From 264af78c5834d035e6c612539d0a18f319b0617e Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 31 Mar 2022 13:09:37 -0500 Subject: [PATCH] Get example previewing voices even if one can't be gotten. --- examples/hello_world.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/hello_world.rs b/examples/hello_world.rs index fdfc02d..9cd7d59 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -79,15 +79,13 @@ fn main() -> Result<(), Error> { println!("{:?}", v); } let Features { get_voice, .. } = tts.supported_features(); - if get_voice { - let original_voice = tts.voice()?; - if let Some(original_voice) = original_voice { - for v in &voices { - tts.set_voice(v)?; - tts.speak(format!("This is {}.", v.name()), false)?; - } - tts.set_voice(&original_voice)?; - } + let original_voice = if get_voice { tts.voice()? } else { None }; + for v in &voices { + tts.set_voice(v)?; + tts.speak(format!("This is {}.", v.name()), false)?; + } + if let Some(original_voice) = original_voice { + tts.set_voice(&original_voice)?; } } tts.speak("Goodbye.", false)?;