| # openWakeWord C++ 推理 |
|
|
| 本目录提供 AX650 和 AX630C C++ 推理程序。WAV、STFT、mel 和缓存更新在 CPU |
| 端完成,embedding 与 classifier 使用对应平台的 `axmodel`。 |
|
|
| ## 编译环境 |
|
|
| AX650 与 AX630C 共用 Arm GNU 9.2 AArch64 交叉编译器: |
|
|
| ```bash |
| mkdir -p cpp/toolchains |
| wget -P cpp/toolchains \ |
| https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz |
| tar -xf cpp/toolchains/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz \ |
| -C cpp/toolchains |
| ``` |
|
|
| 下载 BSP: |
|
|
| ```bash |
| bash cpp/download_bsp.sh all |
| ``` |
|
|
| | 平台 | BSP 压缩包 | 编译目录 | |
| | --- | --- | --- | |
| | AX650 | `msp_50_3.10.2.zip` | `cpp/toolchains/ax650n_bsp_sdk/msp/out` | |
| | AX630C | `msp_20e_3.0.0.zip` | `cpp/toolchains/ax620e_bsp_sdk/msp/out/arm64_glibc` | |
|
|
| ## 交叉编译 |
|
|
| ```bash |
| export TOOLCHAIN_ROOT="cpp/toolchains/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu" |
| |
| bash cpp/build_ax650.sh |
| bash cpp/build_ax630c.sh |
| ``` |
|
|
| 生成: |
|
|
| ```text |
| cpp/bin/openwakeword_ax650 |
| cpp/bin/openwakeword_ax630c |
| ``` |
|
|
| 如 BSP 放在其他位置,可设置 `BSP_MSP_DIR`。AX650 应指向包含 `include/` 和 |
| `lib/` 的 `msp/out`;AX630C 应指向 `msp/out/arm64_glibc`。 |
|
|
| ## 板端运行 |
|
|
| AX650 单条推理: |
|
|
| ```bash |
| AUDIO=audio/openwakeword/alexa_test.wav \ |
| bash cpp/run_openwakeword_ax650.sh |
| ``` |
|
|
| AX630C 单条推理: |
|
|
| ```bash |
| AUDIO=audio/openwakeword/alexa_test.wav \ |
| bash cpp/run_openwakeword_ax630c.sh |
| ``` |
|
|
| 批量测试: |
|
|
| ```bash |
| THRESHOLD=0.5 bash cpp/run_batch_openwakeword_ax650.sh |
| THRESHOLD=0.5 bash cpp/run_batch_openwakeword_ax630c.sh |
| ``` |
|
|
| 模型目录必须与平台对应: |
|
|
| ```text |
| models/650/ |
| models/630C/ |
| ``` |
|
|
| 运行脚本会检查 embedding 和 6 个 classifier 模型,避免误用其他平台的 axmodel。 |
| 输入音频必须为 16 kHz、单声道、16-bit PCM WAV。 |
|
|
| 单条推理会输出 classifier 分数和 `WAKEUP`,并只输出一个 `rtf`。`rtf` 包含 |
| CPU mel 和 NPU 推理,不包含一次性模型加载与初始化。 |
|
|
| 阈值可通过环境变量调整: |
|
|
| ```bash |
| THRESHOLD=0.6 AUDIO=audio/openwakeword/hey_mycroft_test.wav \ |
| bash cpp/run_openwakeword_ax630c.sh |
| ``` |
|
|