mirror of
https://github.com/dscripka/openWakeWord.git
synced 2026-08-27 18:17:20 -04:00
Improved error handling and tests for custom verifier model
This commit is contained in:
parent
89b63051b6
commit
79bb73eb26
2 changed files with 22 additions and 0 deletions
|
|
@ -151,6 +151,10 @@ def train_custom_verifier(
|
|||
[get_reference_clip_features(i, oww, model_name, N=5)
|
||||
for i in tqdm(positive_reference_clips, desc="Processing positive reference clips")]
|
||||
)
|
||||
if positive_features.shape[0] == 0:
|
||||
raise ValueError("The positive features were created! Make sure that"
|
||||
" the positive reference clips contain the appropriate audio"
|
||||
" for the desired model")
|
||||
|
||||
# Get features from negative reference clips
|
||||
negative_features = np.vstack(
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import os
|
|||
import numpy as np
|
||||
import scipy.io.wavfile
|
||||
import tempfile
|
||||
import pytest
|
||||
|
||||
|
||||
# Tests
|
||||
|
|
@ -46,6 +47,15 @@ class TestModels:
|
|||
reference_clips = [os.path.join("tests", "data", "hey_mycroft_test.wav")]
|
||||
negative_clips = [os.path.join(tmp_dir, "negative_reference.wav")]
|
||||
|
||||
# Check for error message when no positive examples are found
|
||||
with pytest.raises(ValueError):
|
||||
openwakeword.train_custom_verifier(
|
||||
positive_reference_clips=reference_clips,
|
||||
negative_reference_clips=negative_clips,
|
||||
output_path=os.path.join(tmp_dir, 'verifier_model.pkl'),
|
||||
model_name="alexa"
|
||||
)
|
||||
|
||||
# Train verifier model on the reference clips
|
||||
openwakeword.train_custom_verifier(
|
||||
positive_reference_clips=reference_clips,
|
||||
|
|
@ -54,6 +64,14 @@ class TestModels:
|
|||
model_name="hey_mycroft"
|
||||
)
|
||||
|
||||
# Train verifier model on the reference clips, using full path of model file
|
||||
openwakeword.train_custom_verifier(
|
||||
positive_reference_clips=reference_clips,
|
||||
negative_reference_clips=negative_clips,
|
||||
output_path=os.path.join(tmp_dir, 'verifier_model.pkl'),
|
||||
model_name=os.path.join("openwakeword", "resources", "models", "hey_mycroft_v0.1.onnx")
|
||||
)
|
||||
|
||||
# Load model with verifier model
|
||||
owwModel = openwakeword.Model(
|
||||
wakeword_model_paths=[os.path.join("openwakeword", "resources", "models", "hey_mycroft_v0.1.onnx")],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue