Skip to main content

Keyword Spotting (KWS)

KWS (Keyword Spotting) detects a specific wake word or keyword in real time. AI algorithms continuously listen to ambient audio and, at low power, quickly detect a preset wake word so a device can leave standby and start voice interaction. KWS is a foundation for smart speakers, assistants, in-vehicle systems, smart homes, and robot voice interaction. It enables button-free wake-up, reduces power consumption, and makes interaction more convenient.

HardwareModelPerformance benchmark
RDK X5
USB speaker / wired headset
zipformerKeyword: 你好地瓜
RTF (inference_time_seconds/audio_seconds): 0.2 (single-core CPU)

Hardware Connection

  • Plug a USB speaker into a USB port on the RDK X5 development board.
  • Plug a wired headset into the earphone audio jack on the RDK X5 development board.

Environment Setup

Install Dependencies

sudo apt update
sudo apt install libasound2-dev

Build sherpa-onnx

Caution
  • CMake pulls dependency code. Make sure GitHub is reachable; retry if it fails.
  • If you have already built it, skip this step.
wget https://archive.d-robotics.cc/downloads/rdk_demo/rdk_x5_demo/sherpa-onnx.tar.gz
tar zxvf sherpa-onnx.tar.gz
cd sherpa-onnx
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j6
make install .

Get the Sample Code and Build

wget https://archive.d-robotics.cc/downloads/rdk_demo/rdk_x5_demo/kws_demo_cpp.tar.gz
tar zxvf kws_demo_cpp.tar.gz
cd kws_demo_cpp
cmake -S . -B build
cmake --build build -j6

Run the Sample

Tip
  • This feature captures microphone input for KWS. Try it in a quiet environment. A noise-canceling audio device is recommended.
  • The keyword list is in the sample code: kws_demo_cpp/sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01/keywords_raw.txt
  • For custom keywords, see zipformer.
  • To specify the audio device at runtime, see Earphone Audio Jack.
# Run from the kws_demo_cpp directory
./build/kws_microphone --device plughw:0,0
KWS running result