From a6df3afd82ca63f8fa8543c6b3779c47a2fbb879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81lvarez?= Date: Sat, 11 Jun 2022 13:51:53 +0200 Subject: [PATCH] v0.16.0: release candidate v1 --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/cli/build_model.rs | 8 ++++---- src/cli/spot.rs | 7 ++----- src/cli/test_model.rs | 5 ++--- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3a7414..01f1f9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "rustpotter" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ffea90f28d614196a430c702cb451f981bdab327896f8fc4694b3dcb08a6e3" +checksum = "0bf4238739059160f575a8afa84e18c220cac055da79f352a2f6764b26ea64eb" dependencies = [ "hound", "log", @@ -443,7 +443,7 @@ dependencies = [ [[package]] name = "rustpotter-cli" -version = "0.15.0" +version = "0.16.0" dependencies = [ "clap", "ctrlc", diff --git a/Cargo.toml b/Cargo.toml index 9db47b9..169dbb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustpotter-cli" -version = "0.15.0" +version = "0.16.0" edition = "2021" license = "Apache-2.0" description = "CLI for Rustpotter, an open source wake word spotter forged in rust" @@ -8,7 +8,7 @@ authors = ["Miguel Álvarez Díez "] repository = "https://github.com/GiviMAD/rustpotter" [dependencies] -rustpotter = { version = "0.15.0", features = ["log", "vad"] } +rustpotter = { version = "0.16.0", features = ["log", "vad"] } log = "0.4.6" pv_recorder = "1.0.2" ctrlc = "3.2.2" diff --git a/src/cli/build_model.rs b/src/cli/build_model.rs index 31bbaba..79c19b6 100644 --- a/src/cli/build_model.rs +++ b/src/cli/build_model.rs @@ -43,20 +43,20 @@ pub fn build(command: BuildModelCommand) -> Result<(), String> { enable_rustpotter_log(); } let mut word_detector = WakewordDetectorBuilder::new().build(); - word_detector.add_wakeword( + word_detector.add_wakeword_with_wav_files( &command.model_name, false, command.averaged_threshold, command.threshold, command.sample_path, - ); + ).map_err(|e| e.to_string())?; match word_detector.generate_wakeword_model_file(command.model_name.clone(), command.model_path) { Ok(_) => { println!("{} created!", command.model_name); } - Err(message) => { - clap::Error::raw(clap::ErrorKind::InvalidValue, message + "\n").exit(); + Err(error) => { + clap::Error::raw(clap::ErrorKind::InvalidValue, error.to_string() + "\n").exit(); } }; Ok(()) diff --git a/src/cli/spot.rs b/src/cli/spot.rs index a144304..bc73b7d 100644 --- a/src/cli/spot.rs +++ b/src/cli/spot.rs @@ -75,13 +75,10 @@ pub fn spot(command: SpotCommand) -> Result<(), String> { .set_eager_mode(command.eager_mode) .set_single_thread(command.single_thread) .build(); - let mut wakeword_names: Vec = Vec::new(); for path in command.model_path { let result = word_detector.add_wakeword_from_model_file(path, true); - if result.is_err() { - clap::Error::raw(clap::ErrorKind::InvalidValue, result.unwrap_err() + "\n").exit(); - } else { - wakeword_names.push(result.unwrap()); + if let Err(error) = result { + clap::Error::raw(clap::ErrorKind::InvalidValue, error.to_string() + "\n").exit(); } } let mut recorder_builder = RecorderBuilder::new(); diff --git a/src/cli/test_model.rs b/src/cli/test_model.rs index f7f406a..b32f932 100644 --- a/src/cli/test_model.rs +++ b/src/cli/test_model.rs @@ -46,11 +46,10 @@ pub fn test(command: TestModelCommand) -> Result<(), String> { .set_sample_format(wav_specs.sample_format) .set_channels(wav_specs.channels) .build(); - let add_wakeword_result = word_detector.add_wakeword_from_model_file(command.model_path, true); - if add_wakeword_result.is_err() { + if let Err(error) = word_detector.add_wakeword_from_model_file(command.model_path, true) { clap::Error::raw( clap::ErrorKind::InvalidValue, - add_wakeword_result.unwrap_err() + "\n", + error.to_string() + "\n", ) .exit(); }