README.md 1,9 КБ
Newer Older
OMP Education's avatar
OMP Education включено в состав коммита
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[RU](README.ru.md) | [**EN**](README.md)

# Wake word classifier training example

This directory contains a simplified, self-contained example of the training
loop used for the wake word classifier bundled with the application:

```text
16 kHz mono PCM WAV
-> openWakeWord-compatible ONNX feature extractor (from ../models)
-> small PyTorch DNN classifier
-> ONNX export in the format the application loads
```

It is an educational example, not the production training pipeline.
The bundled `models/privet_avrora*.onnx` classifiers were trained on a much
larger internal dataset that is not distributed with this repository.

## Layout

- `train_wakeword.py` — the training script.
- `requirements.txt` — Python dependencies.
- `demo_dataset/` — a tiny set of real recordings for demonstration
  (see [demo_dataset/README.md](demo_dataset/README.md)); extend it with
  your own recordings to experiment.

## Usage

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python3 train_wakeword.py
```

The script loads clips from `demo_dataset/`, extracts embeddings with the
ONNX models from `../models`, trains the classifier, prints validation
metrics (TP/TN/FP/FN, recall), and writes the result to `outputs/`:

- `wakeword_classifier.onnx` — classifier in the same format as
  `../models/privet_avrora.onnx` (input `features`, output `score`).
- `wakeword_classifier_metadata.json` — shapes and validation metrics.

Useful options:

```bash
python3 train_wakeword.py --epochs 50 --batch-size 8 --layer-size 64 \
    --dataset /path/to/my_dataset --output-dir /path/to/outputs
```

## Notes

- CPU is enough; the dataset and the model are tiny.
- The feature extraction pipeline in `train_wakeword.py` mirrors the C++
  code in `../src/wakeworddetector.cpp` step by step, so a classifier
  exported here can be dropped into the application next to (or instead of)
  the bundled one.