Skip to main content

Run your_chat_bot on DshanPi-A1

Run the TuyaOpen your_chat_bot voice assistant on the DshanPi-A1 board. Unlike a Raspberry Pi, the DshanPi-A1 has a built-in microphone and speaker, so the two board-specific steps are configuring the onboard sound card and pointing the firmware at the wake-word model.

Prerequisitesโ€‹

Read the Quick Start and its sub-sections first:

note

your_chat_bot is a cloud-paired AI application. You need a valid authorization code (ๆŽˆๆƒ็ ) before the device can connect and respond.

Build methodsโ€‹

DshanPi-A1 supports two build methods:

  • Cross-compilation: build on a PC, then transfer the binary to the board and run it.
  • Native build: build directly on the board.

The build system detects the current platform and selects the appropriate method automatically.

note

Cross-compilation is not supported on macOS. Use Linux, or build directly on the board.

Step 1: Configure the onboard sound cardโ€‹

The DshanPi-A1 has a built-in microphone and speaker, but they must be configured before use.

Install the audio libraryโ€‹

Install the ALSA library for audio input and output:

sudo apt-get install libasound2-dev

Configure speaker outputโ€‹

The DshanPi-A1 has two audio outputs: the headphone jack and the onboard speaker. To set the onboard speaker as the default output, edit the audio configuration file:

sudo vi /etc/asound.conf

Add the following content:

pcm.speaker_r {
type route
slave.pcm "hw:0,0"
slave.channels 2
ttable.0.1 1
ttable.1.1 0
ttable.0.0 0
ttable.1.0 0
}

Save and exit (press ESC, type :wq, then press Enter).

Step 2: Configure the wake-word modelโ€‹

The KWS (Keyword Spotting) model lets the device recognize the wake word "ไฝ ๅฅฝๆถ‚้ธฆ" (Hello Tuya). Obtain the model files, then point the firmware at them.

Obtain the model filesโ€‹

Option 1: Automatic download

When you build for the DshanPi-A1 platform, the model is downloaded automatically to:

platform/LINUX/tuyaos_adapter/src/tkl_audio/models

Option 2: Manual download

Download mdtc_chunk_300ms.mnn and tokens.txt to ~/tuyaopen_models:

wget -P ~/tuyaopen_models https://github.com/tuya/TuyaOpen-ubuntu/raw/platform_ubuntu/tuyaos_adapter/src/tkl_audio/models/mdtc_chunk_300ms.mnn
wget -P ~/tuyaopen_models https://github.com/tuya/TuyaOpen-ubuntu/raw/platform_ubuntu/tuyaos_adapter/src/tkl_audio/models/tokens.txt

The default path in the code is ~/tuyaopen_models. To use a different path, configure it as shown below.

Set the model pathโ€‹

  1. Go to the project directory:

    cd apps/tuya.ai/your_chat_bot
  2. Select the DshanPi-A1 configuration:

    tos.py config choice

    In the menu, choose DshanPi_A1.config.

  3. Open the config menu:

    tos.py config menu
  4. Navigate to (Top) โ†’ Choice a board โ†’ LINUX โ†’ TKL Board Configuration.

  5. Set these two options to the actual paths of the model files:

    • KWS model file path โ€” full path to mdtc_chunk_300ms.mnn
    • KWS model token file path โ€” full path to tokens.txt

Configuration exampleโ€‹

When the model files are in ~/tuyaopen_models, configure the paths like this:

Example KWS model path configuration in the TKL Board Configuration menu
Example KWS model path configuration in the TKL Board Configuration menu

warning

Set the paths correctly. Otherwise the wake-word feature does not work.

Transfer the binary (cross-compilation only)โ€‹

If you cross-compile on a PC, copy the built executable to the board with scp:

scp ./dist/your_chat_bot_1.0.1/your_chat_bot_QIO_1.0.1.bin username@192.168.1.xxx:~/

Parameters:

  • username โ€” username on the board
  • 192.168.1.xxx โ€” IP address of the board
  • ~/ โ€” target directory on the board

Run the executableโ€‹

./your_chat_bot_QIO_1.0.1.bin

your_chat_bot_QIO_1.0.1.bin is the executable file name.

On the first run, you must perform device network configuration (pairing). If pairing or network connection fails, delete the tuyadb folder and run the program again.

FAQโ€‹

The voice wake word does not work.

Check that the model file paths are correct and the files are complete. Run ls -lh to confirm the files exist and their sizes are as expected.

The executable does not run.

Check that the executable has execute permission. Run chmod +x your_chat_bot_QIO_1.0.1.bin to grant it.