MaixCAM MaixPy Real-time voice recognition
Update history
Date | Version | Author | Update content |
---|---|---|---|
2024-10-08 | 1.0.0 | 916BGAI | Initial document |
1. Introduction#
MaixCAM
has ported the Maix-Speech
offline speech library, enabling continuous Chinese numeral recognition, keyword recognition, and large vocabulary speech recognition capabilities. It supports audio recognition in PCM
and WAV
formats, and can accept input recognition via the onboard microphone.
2. Maix-Speech#
Maix-Speech
is an offline speech recognition library specifically designed for embedded environments. It has been deeply optimized for speech recognition algorithms, significantly reducing memory usage while maintaining excellent recognition accuracy. For detailed information, please refer to the Maix-Speech Documentation.
3. Continuous Large Vocabulary Speech Recognition#
3.1. Usage#
- Import the
app
andnn
modules
- Load the acoustic model
- You can also load the
am_7332
acoustic model; larger models provide higher accuracy but consume more resources.
- Choose the corresponding audio device
- This uses the onboard microphone and supports both
WAV
andPCM
audio as input.
- Note that
WAV
must be16KHz
sample rate withS16_LE
storage format. You can use thearecord
tool for conversion.
- When recognizing
PCM/WAV
, if you want to reset the data source, such as for the next WAV file recognition, you can use thespeech.device
method, which will automatically clear the cache:
- Set up the decoder
The user can configure multiple decoders simultaneously.
lvcsr
decoder is registered to output continuous speech recognition results (for fewer than 1024 Chinese characters).When setting up the
lvcsr
decoder, you need to specify the paths for thesfst
file, thesym
file (output symbol table), the path forphones.bin
(phonetic table), and the path forwords.bin
(dictionary). Lastly, a callback function must be set to handle the decoded data.If a decoder is no longer needed, you can deinitialize it by calling the
speech.dec_deinit
method.
- Recognition
Use the
speech.run
method to run speech recognition. The parameter specifies the number of frames to run each time, returning the actual number of frames processed. Users can choose to run 1 frame each time and then perform other processing, or run continuously in a single thread, stopping it with an external thread.To clear the cache of recognized results, you can use the
speech.clear
method.When switching decoders during recognition, the first frame after the switch may produce incorrect results. You can use
speech.skip_frames(1)
to skip the first frame and ensure the accuracy of subsequent results.
3.2. Recognition Results#
If the above program runs successfully, speaking into the onboard microphone will yield real-time speech recognition results, such as: