Rustpotter

A personal keywords spotter written in Rust

Description

This project allows detect concrete words on and audio stream, to do so it generates a set of features from some word audio samples to later compare them with the features generated from a live audio stream, to calculate the probability of a match.

The features can be loaded from a previous generated model file or extracted from the samples before start the live streaming.

Some examples:

Create keyword model

rust let mut detector_builder = detector::FeatureDetectorBuilder::new(); let mut word_detector = detector_builder.build(|_| panic!("Never")); let name = String::from("hey home"); let path = String::from("./hey_home.rpw"); word_detector.add_keyword( name.clone(), false, true, None, vec!["./<audio sample path>.wav", "./<audio sample path>2.wav", ...], ); match word_detector.create_wakeword_model(name.clone(), path) { Ok(_) => { println!("{} created!", name); } Err(message) => { panic!(message); } };

Spot keyword:

```rust let mut detectorbuilder = detector::FeatureDetectorBuilder::new(); detectorbuilder.setthreshold(0.4); let mut worddetector = detectorbuilder.build(|kw| println!("Detected {} - {}!", kw.wakeword, kw.score)); let result = worddetector.addkeywordfrommodel(command.modelpath, command.averagetemplates, true, None); if result.iserr() { panic!("Unable to load keyword model"); } while true { let mut framebuffer = vec![0; worddetector.getsamplesperframe()]; let pcmsignedbuffer: Vec = ...; worddetector.processpcmsigned(frame_buffer); }

```

References

This project is mostly a port of the project node-personal-wakeword with some utils ported from Gist so credit about the implementation is for those projects. Also to this medium article about wake word detection

Motivation

The motivation behind this project is to learn about audio analysis and Rust, also to have access to an open source personal wakeword spotter to use in other home projects. Feel free to propose or PR any improvements or fixes.