pub struct WakewordDetector { /* private fields */ }
Expand description

This struct manages the wakeword generation and the spotting functionality.

use rustpotter::{WakewordDetectorBuilder};
// assuming the audio input format match the detector defaults
let mut word_detector = WakewordDetectorBuilder::new().build();
// load and enable a wakeword
word_detector.add_wakeword_from_model_file("./tests/resources/oye_casa.rpw".to_owned(), true).unwrap();
let mut frame_buffer: Vec<i32> = vec![0; word_detector.get_samples_per_frame()];
// while true { Iterate forever
    // fill the buffer with new samples...
    let detection_option = word_detector.process(&frame_buffer);
    if detection_option.is_some() {
        let detection = detection_option.as_ref().unwrap();
        println!(
            "Detected '{}' with score {}!",
            detection.wakeword,
            detection.score,
        );
    }
// }

Implementations

Creates a new WakewordDetector.

It is recommended to use the WakewordDetectorBuilder struct instead.

Loads a wakeword from its model bytes.

Loads a wakeword from its model path.

Generates the model file bytes from a trained a wakeword. Asserts training mode is enabled.

Generates a model file from a trained a wakeword on the desired path. Asserts training mode is enabled.

Generates the model file bytes from a loaded a wakeword.

Generates a model file from a loaded a wakeword on the desired path.

Adds a wakeword using wav samples.

use rustpotter::{WakewordDetectorBuilder};
let mut word_detector = WakewordDetectorBuilder::new().build();
word_detector.add_wakeword(
    "model_name",
    true,
    Some(0.35),
    Some(0.6),
    vec![],
);
// Save as model file
// word_detector.generate_wakeword_model_file("model_name".to_owned(), "model_path".to_owned()).unwrap();

Removes a wakeword by name.

Sets detector threshold.

Sets detector averaged threshold.

Sets wakeword threshold.

Sets wakeword averaged threshold.

Process bytes buffer.

Asserts that the buffer length should match the return of the get_bytes_per_frame method.

Assumes sample rate match the configured for the detector.

Assumes little endian order on the buffer.

Asserts that detector bits_per_sample is 8, 16, 24 or 32 (float format only allows 32).

Process i32 audio chunks.

Asserts that the audio chunk length should match the return of the get_samples_per_frame method.

Assumes sample rate match the configured for the detector.

Asserts that detector bits_per_sample is one of: 8, 16, 24, 32.

Asserts that detector sample_format is ‘int’.

It’s an alias for the process_i32 method.

Process i8 audio chunks.

Asserts that the audio chunk length should match the return of the get_samples_per_frame method.

Assumes sample rate match the configured for the detector.

Asserts that detector bits_per_sample is 8.

Asserts that detector sample_format is ‘int’.

Process i16 audio chunks.

Asserts that the audio chunk length should match the return of the get_samples_per_frame method.

Assumes sample rate match the configured for the detector.

Asserts that detector bits_per_sample is one of: 8, 16.

Asserts that detector sample_format is ‘int’.

Process i32 audio chunks.

Asserts that the audio chunk length should match the return of the get_samples_per_frame method.

Assumes sample rate match the configured for the detector.

Asserts that detector bits_per_sample is one of: 8, 16, 24, 32.

Asserts that detector sample_format is ‘int’.

Process f32 audio chunks.

Asserts that the audio chunk length should match the return of the get_samples_per_frame method.

Assumes sample rate match the configured for the detector.

Asserts that detector bits_per_sample is 32.

Asserts that detector sample_format is ‘float’.

Returns the desired chunk size.

Returns size in bytes for the desired chunk

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.