[Raspi][SnowBoy][Tutorial] Raspberry Pi SnowBoy Building Tutorial

1. Why use SnowBoy

The project requires a voice assistant, but there are too few wake-up methods supported by Xiao Ai and Tmall Genie. After some inquiries, I found snowboy. Several voice assistant wake-ups mentioned above seem to be developed based on snowboy.

2. Start environment construction

1. Obtain SnowBoy source code

Snowboy Github

Just find a directory and clone it

git clone https://github.com/Kitt-AI/snowboy.git

Directory Structure:

image-20221002114502512

2. Compile SnowBoy

My environment is 32-bit Raspberry Pi 4B

Install dependencies first

sudo apt install python3 python3-pyaudio python3-pip libatlas-base-dev portaudio19-dev swig

Enter the SnowBoy compilation directory

cd swig/Python3

compile

make

The compiled file is as follows:

image-20221002115124108

3. Run the samples provided by SnowBoy

Move the compiled library file to the sample file

image-20221002115204417

Go to the sample folder

cd snowboy/examples/Python3

Modify snowboydecoder.pylibrary references:

image-20221002154417520

Run example:

image-20221002153257190

Appears as follows, that is, it is running normally

image-20221002153527967

3. Create your own wake word

The official website is already broken. Here, according to the snowboy stopped API service, this ISSUE found a third-party

To enter the website, you need to record the wake-up word three times, then name the model, download it, and don’t go into details

After downloading the model, you can test and run your own model

python3 <filename> <model_file>

Here I put the model in another folder and modify it according to my own situation

image-20221002160102341

4. Migrate to the project

1. Move the necessary files to the folder in your project

The necessary documents aresnowboydetect.py _snowboydetect.so snowboydecoder.py demo.py

There is also a folder resourceswhere the model is stored. If you have your own model, you don’t need to copy this

2. Encapsulate the folder into a library

The Python package library is very simple, just create a new one under the folder __init__.py(empty file is fine)

Use the library:

from <dic>.<dic> import snowdecoder

At this time, an error that the library cannot be found may be reported, just modify the location of the library reference in the corresponding file

3. Write the project master file

Copy the content in the demo.py file to the main project and run it.

Advanced is naturally to write the demo file by yourself, just learn how to use the API in the demo file

4. Run the program

Since the form of the command line to run is , it is enough python3 <filename> <model_file>to add parameters to the pycharm's running command and specify it directlymodel_file

image-20221002155317211

.bckThen click to run ( the and in the directory Makefileare useless, don’t worry about it, only the four files mentioned above plus a file for building the library plus a folder are useful, it nihaoxiaoyao_model.pmdl’s my own model file, don’t worry about it)

image-20221002155413529

5. Reference

Raspberry Pi uses snowboy and Baidu voice api to implement voice recognition assistant

A detailed tutorial on compiling and running Snowboy on the Raspberry Pi.

snowboy stopped the API service

Guess you like

Origin blog.csdn.net/qq_38844263/article/details/127143725