mirror of
https://github.com/espressif/esp-sr.git
synced 2025-09-15 15:28:44 +08:00
Merge branch 'docs/review_cn_doc' into 'master'
fix broken links See merge request speech-recognition-framework/esp-sr!8
This commit is contained in:
commit
fd92805910
@ -14,7 +14,7 @@ high-quality audio data for further wake-up or speech recognition.
|
||||
|
||||
Espressif AFE is divided into two sets of algorithms:
|
||||
|
||||
#. for speech recognition scenarios;
|
||||
#. for speech recognition scenarios;
|
||||
#. for voice communication scenarios. Shown as below:
|
||||
|
||||
- Speech recognition scenarios
|
||||
@ -44,8 +44,8 @@ The workflow is as follows:
|
||||
(``voice_communication_init`` needs to be configured as false)
|
||||
#. AFE feed: Input audio data and will run AEC in the feed function
|
||||
#. Internal: BSS/NS algorithm processing will be carried out.
|
||||
#. AFE fetch: Return the audio data and the related information after processing. VAD processing and wake-up word detection will be carried out inside the fetch. The specific behavior depends on the config of ``afe_config_t`` structure.
|
||||
|
||||
#. AFE fetch: Return the audio data and the related information after processing. VAD processing and wake-up word detection will be carried out inside the fetch. The specific behavior depends on the config of ``afe_config_t`` structure.
|
||||
|
||||
.. note ::
|
||||
``wakenet_Init`` and ``voice_communication_Init`` cannot be configured to true at the same time
|
||||
|
||||
@ -95,7 +95,7 @@ For the acquisition of AFE handle, there is a slight difference between speech r
|
||||
Input Audio Data
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The AFE supports two kinds of scenarios: single MIC and dual MIC. The number of channels can be configured according to the audio of ``afe->feed()``. Modify method: It can modify the ``pcm_config`` configuration in macro ``AFE_CONFIG_DEFAULT()``. It supports the following configuration combinations
|
||||
The AFE supports two kinds of scenarios: single MIC and dual MIC. The number of channels can be configured according to the audio of ``afe->feed()``. Modify method: It can modify the ``pcm_config`` configuration in macro ``AFE_CONFIG_DEFAULT()``. It supports the following configuration combinations
|
||||
|
||||
.. note ::
|
||||
It must meet ``total_ch_num = mic_num + ref_num`` :
|
||||
@ -134,7 +134,7 @@ The input data is arranged as follows:
|
||||
:alt: input data of dual MIC
|
||||
:height: 0.75in
|
||||
|
||||
.. note::
|
||||
.. note::
|
||||
the converted data size is: ``afe->get_feed_chunksize * channel number * sizeof(short)``
|
||||
|
||||
AEC Introduction
|
||||
@ -248,8 +248,8 @@ Users can adjust the switch of each algorithm module and its corresponding param
|
||||
|
||||
- vad_mode: The VAD operating mode. The bigger, the more radical.
|
||||
|
||||
- wakenet_model_name: Its default value is NULL in macro ``AFE_CONFIG_DEFAULT()``. At first, you need to choose WakeNet model through ``idf.py menuconfig``. Then you need to assign a specific model name to this place before ``afe_handle->create_from_config``. The type of value is string. Please refer to `flash_model <../flash_model/README.md>`__
|
||||
.. note::
|
||||
- wakenet_model_name: Its default value is NULL in macro ``AFE_CONFIG_DEFAULT()``. At first, you need to choose WakeNet model through ``idf.py menuconfig``. Then you need to assign a specific model name to this place before ``afe_handle->create_from_config``. The type of value is string. Please refer to :doc:`flash_model <../flash_model/README>` .
|
||||
.. note::
|
||||
In the example, we use the ``esp_srmodel_filter()`` to get wakenet_model_name. If you choose the multiple wakenet models coexist through menuconfig, this function will return a model name randomly.
|
||||
|
||||
- wakenet_mode: Wakenet mode. It indicate the number of wake-up channels according to the number of MIC channels.
|
||||
@ -303,7 +303,7 @@ The user uses the ``afe_handle->create_from_config(&afe_config)`` function to ob
|
||||
|
||||
/**
|
||||
* @brief Function to initialze a AFE_SR instance
|
||||
*
|
||||
*
|
||||
* @param afe_config The config of AFE_SR
|
||||
* @returns Handle to the AFE_SR data
|
||||
*/
|
||||
@ -325,8 +325,8 @@ The input audio size and layout format can refer to the step **Input Audio data*
|
||||
* The last channel is reference signal if it has reference data.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
*
|
||||
* @param in The input microphone signal, only support signed 16-bit @ 16 KHZ. The frame size can be queried by the
|
||||
*
|
||||
* @param in The input microphone signal, only support signed 16-bit @ 16 KHZ. The frame size can be queried by the
|
||||
* `get_feed_chunksize`.
|
||||
* @return The size of input
|
||||
*/
|
||||
@ -340,7 +340,7 @@ Get the number of audio channels:
|
||||
|
||||
/**
|
||||
* @brief Get the total channel number which be config
|
||||
*
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The amount of total channels
|
||||
*/
|
||||
@ -407,7 +407,7 @@ When users need to perform other operations after wake-up, such as offline or on
|
||||
|
||||
Users can call ``afe_handle->disable_wakenet(afe_data)`` to stop WakeNet, or call ``afe_handle->enable_wakenet(afe_data)`` to enable WakeNet.
|
||||
|
||||
In addition, ESP32S3 chip supports switching between wakenet words. (Note: ESP32 chip only supports one wake-up word and does not support switching). After AFE initialization, the ESP32S3 can switch wakenet word by ``afe_handle->set_wakenet()``. For example, ``afe_handle->set_wakenet(afe_data, "wn9_hilexin")`` can switch to the "Hi Lexin". How to configure multiple wakenet words, please refer to: `flash_model <../flash_model/README.md>`__
|
||||
In addition, ESP32S3 chip supports switching between wakenet words. (Note: ESP32 chip only supports one wake-up word and does not support switching). After AFE initialization, the ESP32S3 can switch wakenet word by ``afe_handle->set_wakenet()``. For example, ``afe_handle->set_wakenet(afe_data, "wn9_hilexin")`` can switch to the "Hi Lexin". How to configure multiple wakenet words, please refer to: :doc:`flash_model <../flash_model/README>`
|
||||
|
||||
Usage Of AEC
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@ -54,7 +54,7 @@ This option is turned on by default. When the user only uses ``AEC`` or ``BSS``,
|
||||
- Select wake words by menuconfig, ``ESP Speech Recognition -> Select wake words``. The model name of wake word in parentheses is used to initialize wakenet handle. |select wake wake|
|
||||
- If you want to select multiple wake words, please select ``Load Multiple Wake Words`` ( **Note this option only supports ESP32S3**) |multi wake wake| Then you can select multiple wake words at the same time |image1|
|
||||
|
||||
For more details, please refer to `WakeNet <../wake_word_engine/README.md>`__ .
|
||||
For more details, please refer to :doc:`WakeNet <../wake_word_engine/README>` .
|
||||
|
||||
Use Multinet
|
||||
~~~~~~~~~~~~
|
||||
@ -102,7 +102,7 @@ The user needs to add Chinese Speech Command words to this item when ``Chinese S
|
||||
|
||||
The user needs to add English Speech Command words to this item when ``Chinese Speech Commands Model`` is not ``None``.
|
||||
|
||||
For more details, please refer to `MultiNet <../speech_command_recognition/README.md>`__ .
|
||||
For more details, please refer to :doc:`MultiNet <../speech_command_recognition/README>` .
|
||||
|
||||
How To Use
|
||||
----------
|
||||
@ -148,7 +148,7 @@ ESP32S3
|
||||
|
||||
//
|
||||
// step1: initialize spiffs and return models in spiffs
|
||||
//
|
||||
//
|
||||
srmodel_list_t *models = esp_srmodel_init("model");
|
||||
|
||||
//
|
||||
@ -159,9 +159,9 @@ ESP32S3
|
||||
char *alexa_wn_name = esp_srmodel_filter(models, ESP_WN_PREFIX, "alexa"); // select wakenet with "alexa" wake word.
|
||||
char *en_mn_name = esp_srmodel_filter(models, ESP_MN_PREFIX, ESP_MN_ENGLISH); // select english multinet model
|
||||
char *cn_mn_name = esp_srmodel_filter(models, ESP_MN_PREFIX, ESP_MN_CHINESE); // select english multinet model
|
||||
|
||||
|
||||
// It also works if you use the model name directly in your code.
|
||||
char *my_wn_name = "wn9_hilexin"
|
||||
char *my_wn_name = "wn9_hilexin"
|
||||
// we recommend you to check that it is loaded correctly
|
||||
if (!esp_srmodel_exists(models, my_wn_name))
|
||||
printf("%s can not be loaded correctly\n")
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
ESP-SR User Guide
|
||||
=================
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
This is LEXIN `ESP-SR <https://github.com/espressif/esp-sr>` This document will introduce LEXIN's AI voice solution based on ESP32 series chip. From front-end audio processing, to voice command word recognition, from hardware design suggestions, to performance testing methods, it is a comprehensive introduction to Loxin's systematic work on AI speech, and provides a strong reference for users to build AIoT applications on Loxin ESP32 series chips and development boards.
|
||||
This is LEXIN `ESP-SR <https://github.com/espressif/esp-sr>`__ This document will introduce LEXIN's AI voice solution based on ESP32 series chip. From front-end audio processing, to voice command word recognition, from hardware design suggestions, to performance testing methods, it is a comprehensive introduction to Loxin's systematic work on AI speech, and provides a strong reference for users to build AIoT applications on Loxin ESP32 series chips and development boards.
|
||||
|
||||
Lexin AFE algorithm has passed the Software Audio Front-End certification for Amazon Alexa built-in devices. The built-in wake-up module in AFE algorithm can realize local voice wake-up function and support wake-up word customization. Lexin's voice command word recognition model can support up to 200 English and Chinese command words, and the command words can be modified during operation, bringing great flexibility to the application.
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ The following table shows the model support of Espressif SoCs:
|
||||
| English | | | | √ |
|
||||
+---------+-----------+-------------+---------------+-------------+
|
||||
|
||||
.. note::
|
||||
.. note::
|
||||
Note: the model ending with Q8 represents the 8bit version of the model, means more lightweight.
|
||||
|
||||
Commands Recognition Process
|
||||
@ -85,7 +85,8 @@ Speech commands string need to meet specific formats, as follows:
|
||||
|
||||
English speech commands need to be represented by specific phonetic symbols. The phonetic symbols of each word are separated by spaces, such as "turn on the light", which needs to be written as "TkN nN jc LiT".
|
||||
|
||||
**We provide specific conversion rules and tools. For details, please refer to the English G2P** `tool <../../tool/multinet_g2p.py>`__.
|
||||
|
||||
We provide specific conversion rules and tools. For details, please refer to the English G2P `tool <../../tool/multinet_g2p.py>`_ .
|
||||
|
||||
Set speech commands offline
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -135,16 +136,13 @@ Set speech commands online
|
||||
|
||||
MultiNet supports online dynamic addition / deletion / modification of speech commands during operation, without changing models or adjusting parameters. For details, please refer to the example in ESP-Skainet.
|
||||
|
||||
Please refer to
|
||||
`esp_mn_speech_commands <../../src/esp_mn_speech_commands.c>`__ for
|
||||
details of APIs:
|
||||
|
||||
Please refer to `esp_mn_speech_commands <../../src/esp_mn_speech_commands.c>`_ for details of APIs:
|
||||
Run speech commands recognition
|
||||
----------------------------------
|
||||
|
||||
Speech commands recognition needs to be run together with the audio front-end (AFE) in esp-sr (WakeNet needs to be enabled in AFE). For the use of AFE, please refer to the document:
|
||||
|
||||
`AFE Introduction and Use <../audio_front_end/README_CN.md>`__
|
||||
:doc:`AFE Introduction and Use <../audio_front_end/README>`
|
||||
|
||||
MultiNet Initialization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -36,7 +36,7 @@ Espressif provides users with the offline wake word customization service, which
|
||||
|
||||
#. If you want to use offline command words
|
||||
|
||||
- Please set them by yourself referring to `esp-sr <https://github.com/espressif/esp-sr/tree/c5896943ea278195968c93c8b3466c720e641ebc speech_command_recognition>`__ algorithm. They do not need additional customization.
|
||||
- Please set them by yourself referring to `esp-sr <https://github.com/espressif/esp-sr>`__ algorithm. They do not need additional customization.
|
||||
- Similar to speech wake words, the effect of command words is also related to hardware designs, so please refer to *Espressif MIC Design Guidelines*.
|
||||
|
||||
Requirements on Corpus
|
||||
|
||||
@ -31,12 +31,12 @@ Please see the flow diagram of wakeNet below:
|
||||
The wakeNet uses `MFCC <https://en.wikipedia.org/wiki/Mel-frequency_cepstrum>`__ to obtain the features of the input audio clip (16 KHz, 16 bit, single track). The window width and step width of each frame of the audio clip are both 30 ms.
|
||||
|
||||
- Neural Network:
|
||||
|
||||
|
||||
Now, the neural network structure has been updated to the ninth edition, among which:
|
||||
|
||||
- wakeNet1,wakeNet2,wakeNet3,wakeNet4,wakeNet6,wakeNet7 had been out of use.
|
||||
- wakeNet5 only support ESP32 chip.
|
||||
- wakeNet8,wakeNet9 only support ESP32S3 chip, which are built upon the `Dilated Convolution <https://arxiv.org/pdf/1609.03499.pdf>`__ structure.
|
||||
- wakeNet8,wakeNet9 only support ESP32S3 chip, which are built upon the `Dilated Convolution <https://arxiv.org/pdf/1609.03499.pdf>`__ structure.
|
||||
|
||||
.. note:: text
|
||||
The network structure of wakeNet5,wakeNet5X2 and wakeNet5X3 is same, but the parameter of wakeNetX2 and wakeNetX3 is more than wakeNet5. Please refer to `Performance Test <#performance-test>`__ for details.
|
||||
@ -72,11 +72,11 @@ Use wakeNet
|
||||
|
||||
- How to select the wakeNet model
|
||||
|
||||
Please refer to `flash model <../flash_model/README.rst>`__.
|
||||
Please refer to :doc:`flash model <../flash_model/README>` .
|
||||
|
||||
- How to run wakeNet
|
||||
|
||||
wakeNet is currently included in the `AFE <../audio_front_end/README.rst>`__, which is running by default, and returns the detect results through the AFE fetch interface.
|
||||
wakeNet is currently included in the :doc:`AFE <../audio_front_end/README>`, which is running by default, and returns the detect results through the AFE fetch interface.
|
||||
|
||||
If users do not wants to initialize WakeNet, please use:
|
||||
|
||||
@ -94,9 +94,9 @@ Use wakeNet
|
||||
Performance Test
|
||||
----------------
|
||||
|
||||
Please refer to `Performance Test <../benchmark/README.rst>`__.
|
||||
Please refer to :doc:`Performance Test <../benchmark/README>` .
|
||||
|
||||
Wake Word Customization
|
||||
-----------------------
|
||||
|
||||
For details on how to customize your wake words, please see `Espressif Speech Wake Word Customization Process <ESP_Wake_Words_Customization.rst>`__.
|
||||
For details on how to customize your wake words, please see :doc:`Espressif Speech Wake Word Customization Process <ESP_Wake_Words_Customization>` .
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
基于乐鑫的 S3 系列语音开发板,对于整机 Mic 设计要求如下:
|
||||
本指南基于乐鑫的 ESP32-S3 系列语音开发板,对于整机 Mic 设计要求如下:
|
||||
|
||||
麦克风电器性能推荐
|
||||
------------------
|
||||
@ -11,59 +11,59 @@
|
||||
#. 麦克类型:全向型 MEMS 麦克风
|
||||
#. 灵敏度
|
||||
|
||||
- 1Pa 声压下模拟麦灵敏度不低于 -38dBV,数字麦灵敏度要求不低于 -26dB。
|
||||
- 公差控制在 ±2dB,对于麦克阵列推荐采用 ±1dB 公差。
|
||||
- 1 Pa 声压下模拟麦灵敏度不低于 -38 dBV,数字麦灵敏度要求不低于 -26 dB。
|
||||
- 公差控制在 ± 2dB,对于麦克阵列推荐采用 ±1 dB 公差。
|
||||
|
||||
#. 信噪比(SNR)
|
||||
|
||||
- 信噪比- 信噪比不低于 62dB,推荐 >64dB
|
||||
- 频率响应在 50~16KHz 范围内的波动在 ±3dB 之内。
|
||||
- 信噪比:信噪比不低于 62 dB,推荐 > 64 dB
|
||||
- 频率响应在 50~16 KHz 范围内的波动在 ±3 dB 之内
|
||||
- 麦克风(NENS MIC)的 PSRR 应大于 55 dB
|
||||
|
||||
结构设计建议
|
||||
----------------
|
||||
------------
|
||||
|
||||
#. 麦克孔孔径或宽度推荐大于 1mm,拾音管道尽量短,腔体尽可能小,保证麦克和结构组件配合的谐振频率在 9KHz 以上。
|
||||
#. 拾音孔深度和直径比小于 2:1,壳体厚度推荐1mm,如果壳体过厚,需增大开孔面积。
|
||||
#. 麦克孔孔径或宽度推荐大于 1 mm,拾音管道尽量短,腔体尽可能小,保证麦克和结构组件配合的谐振频率在 9KHz 以上。
|
||||
#. 拾音孔深度和直径比小于 2:1,壳体厚度推荐 1 mm,如果壳体过厚,需增大开孔面积。
|
||||
#. 麦克孔上需通过防尘网进行保护。
|
||||
#. 麦克风与设备外壳之间必须加硅胶套或泡棉等进行密封和防震,需进行过盈配合设计,以保证麦克的密封性。
|
||||
#. 麦克孔不能被遮挡,底部拾音的麦克孔需结构上增加凸起,避免麦克孔被桌面等遮挡。
|
||||
#. 麦克需远离喇叭等会产生噪音或振动的物体摆放,且与喇叭音腔之间通过橡胶垫等隔离缓冲。
|
||||
|
||||
麦克阵列设计推荐
|
||||
-----------------------
|
||||
----------------
|
||||
|
||||
#. 麦克类型:全向型硅麦,同一个阵列内的麦克推荐同一厂家同一型号,不建议混用。
|
||||
#. 麦克阵列中各麦克灵敏度差异在 3dB 之内。
|
||||
#. 麦克类型:全向型硅麦,推荐同一个阵列内的麦克应使用同一厂家的同一型号,不建议混用。
|
||||
#. 麦克阵列中各麦克灵敏度差异在 3 dB 之内。
|
||||
#. 相位差:多麦克阵列中麦克之间的相位差控制在 10° 以内。
|
||||
#. 麦克阵列中各麦克的结构设计,推荐采用相同的设计,以保证结构设计的一致性。
|
||||
#. 2 MIC方案:麦克间距要求 4~6.5cm,连接两个麦克风的轴线应平行于水平线,且两个麦克的中心尽量靠近产品水平方向的中心。
|
||||
#. 3 MIC方案:3 个麦克风等间距并且成正圆分布(夹⻆互成 120度),间距要求 4~6.5cm。
|
||||
#. 2 MIC 方案:麦克间距要求 4~6.5 cm,连接两个麦克风的轴线应平行于水平线,且两个麦克的中心尽量靠近产品水平方向的中心。
|
||||
#. 3 MIC 方案:3 个麦克风等间距并且成正圆分布(夹⻆互成 120 度),间距要求 4~6.5 cm。
|
||||
|
||||
麦克风结构密封性
|
||||
----------------
|
||||
|
||||
用橡皮泥等材料封堵麦克拾音孔,密封前后麦克风采集信号的幅度衰减25dB合格,推荐30dB。测试方法:
|
||||
用橡皮泥等材料封堵麦克拾音孔,密封前后麦克风采集信号的幅度衰减 25 dB 为合格,推荐 30 dB。测试方法:
|
||||
|
||||
#. 麦克风正上方 0.5 米处,播放白噪声,麦克风处音量 90dB。
|
||||
#. 使用麦克风阵列录制 10s 以上,存储为录音文件A。
|
||||
#. 用橡皮泥等材料封堵麦克拾音孔,使用麦克风阵列录制 10s 以上,存储为录音文件B。
|
||||
#. 对比两个文件的频谱,需保证100~8KHz频段内整体衰减 25dB 以上。
|
||||
#. 麦克风正上方 0.5 米处,播放白噪声,麦克风处音量 90 dB。
|
||||
#. 使用麦克风阵列录制 10s 以上,存储为录音文件 A。
|
||||
#. 用橡皮泥等材料封堵麦克拾音孔,使用麦克风阵列录制 10s 以上,存储为录音文件 B。
|
||||
#. 对比两个文件的频谱,需保证 100~8 KHz 频段内整体衰减 25dB 以上。
|
||||
|
||||
回声参考信号设计
|
||||
----------------
|
||||
|
||||
#. 回声参考信号推荐尽量靠近喇叭侧,推荐从 DA 后级 PA 前级回采。
|
||||
#. 扬声器音量最大时,输入到麦克的回声参考信号不能有饱和失真,最大音量下喇叭功放输出 THD 满足100Hz 小于 10%,200Hz 小于 6%,350Hz 以上频率,小于 3% 。
|
||||
#. 扬声器音量最大时,麦克处拾音的声压不超过 102dB@1KHz。
|
||||
#. 扬声器音量最大时,输入到麦克的回声参考信号不能有饱和失真,最大音量下喇叭功放输出 THD 满足 100 Hz 小于 10%,200 Hz 小于 6%,350 Hz 以上频率,小于 3%。
|
||||
#. 扬声器音量最大时,麦克处拾音的声压不超过 102 dB (1KHz)。
|
||||
#. 回声参考信号电压不超过 ADC 的最大允许输入电压,电压过高需增加衰减电路。
|
||||
#. 从D类功放输出引参考回声信号需增加低通滤波器,滤波器的截止频率推荐 >22KHz。
|
||||
#. 音量最大播放时,回采信号峰值 -3 到 -5dB。
|
||||
#. 从 D 类功放输出引参考回声信号需增加低通滤波器,滤波器的截止频率推荐 > 22 KHz。
|
||||
#. 音量最大播放时,回采信号峰值 -3 到 -5 dB。
|
||||
|
||||
麦克风阵列一致性验证
|
||||
----------------------------
|
||||
--------------------
|
||||
|
||||
要求各个麦克风采样信号幅度相差小于 3dB,测试方法:
|
||||
要求各个麦克风采样信号幅度相差小于 3 dB,测试方法:
|
||||
|
||||
#. 麦克风正上方 0.5 米处,播放白噪声,麦克风处音量 90dB 。
|
||||
#. 使用麦克风阵列录制 10s 以上,查看各 mic 录音幅度和音频采样率是否一致。
|
||||
#. 麦克风正上方 0.5 米处,播放白噪声,麦克风处音量 90 dB。
|
||||
#. 使用麦克风阵列录制 10s 以上,查看各 MIC 录音幅度和音频采样率是否一致。
|
||||
|
||||
@ -3,87 +3,96 @@ Audio Front-end 框架
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
乐鑫 Audio Front-end(AFE) 算法框架由乐鑫 AI 实验室自主开发。该框架基于 ESP32 系列芯片,能够提供高质量并且稳定的音频数据。
|
||||
乐鑫 Audio Front-end (AFE) 算法框架由乐鑫 AI 实验室自主开发。该框架基于 ESP32 系列芯片,能够提供高质量并且稳定的音频数据。
|
||||
|
||||
概述
|
||||
----
|
||||
|
||||
乐鑫 AFE 框架以最便捷的方式基于乐鑫的 ESP32 系列芯片进行语音前端处理。使用乐鑫 AFE 框架,您可以获取高质量且稳定的音频数据,从而更加方便地构建唤醒或语音识别等应用。
|
||||
乐鑫 AFE 框架基于乐鑫的 ESP32 系列芯片,可以以最便捷的方式进行语音前端处理。使用乐鑫 AFE 框架,您可以获取高质量且稳定的音频数据,从而更加方便地构建唤醒或语音识别等应用。
|
||||
|
||||
乐鑫 AFE 的功能分为两套:
|
||||
乐鑫 AFE 主要有两个使用场景。
|
||||
|
||||
#. 针对语音识别场景;
|
||||
#. 针对语音通话场景。如下所示:
|
||||
|
||||
- 语音识别场景
|
||||
语音识别场景
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. figure:: ../../_static/AFE_SR_overview.png
|
||||
:alt: overview
|
||||
|
||||
|
||||
- 语音通话场景
|
||||
|
||||
.. figure:: ../../_static/AFE_VOIP_overview.png
|
||||
:alt: overview
|
||||
|
||||
|
||||
乐鑫 AFE 的数据流也相应分为两种场景,如下所示:
|
||||
|
||||
- 语音识别场景
|
||||
|
||||
数据流
|
||||
""""""
|
||||
.. figure:: ../../_static/AFE_SR_workflow.png
|
||||
:alt: overview
|
||||
|
||||
工作流程如下:
|
||||
工作流程
|
||||
""""""""
|
||||
|
||||
#. 使用 **ESP_AFE_SR_HANDLE**,进行AFE 的创建和初始化(``voice_communication_init`` 需配置为 false )
|
||||
#. 使用 **ESP_AFE_SR_HANDLE**,进行 AFE 的创建和初始化(注意, ``voice_communication_init`` 需配置为 false)
|
||||
#. AFE feed,输入音频数据,feed 内部会先进行 AEC 算法处理
|
||||
#. 内部: 进行 BSS/NS 算法处理
|
||||
#. AFE fetch,返回处理过的单通道音频数据和相关信息, fetch 内部会进行 VAD 处理,以及唤醒词的检测,具体行为取决于用户对 ``afe_config_t`` 结构体的配置。(注: ``wakenet_init`` 和 ``voice_communication_init`` 不可同时配置为 true)
|
||||
#. AFE fetch,返回处理过的单通道音频数据和相关信息, fetch 内部会进行 VAD 处理,以及唤醒词的检测,具体行为取决于用户对 ``afe_config_t`` 结构体的配置。(注意: ``wakenet_init`` 和 ``voice_communication_init`` 不可同时配置为 true)。
|
||||
|
||||
- 语音通话场景
|
||||
语音通话场景
|
||||
^^^^^^^^^^^^
|
||||
.. figure:: ../../_static/AFE_VOIP_overview.png
|
||||
:alt: overview
|
||||
|
||||
数据流
|
||||
""""""
|
||||
.. figure:: ../../_static/AFE_VOIP_workflow.png
|
||||
:alt: overview
|
||||
|
||||
|
||||
工作流程如下:
|
||||
|
||||
#. 使用 **ESP_AFE_VC_HANDLE** ,进行AFE 的创建和初始化 (``voice_communication_init`` 需配置为 true )
|
||||
工作流程
|
||||
""""""""
|
||||
#. 使用 **ESP_AFE_VC_HANDLE** ,进行 AFE 的创建和初始化 (``voice_communication_init`` 需配置为 true )
|
||||
#. AFE feed,输入音频数据,feed 内部会先进行 AEC 算法处理
|
||||
#. 内部: 首先进行 BSS/NS 算法处理;若为双麦,随后还会进行MISO 算法处理;
|
||||
#. AFE fetch,返回处理过的单通道音频数据和相关信息。其中会进行AGC非线性放大,具体增益值取决于用户对 ``afe_config_t`` 结构体的配置;若为双麦,在AGC之前还会进行降噪处理。(注: ``wakenet_init`` 和 ``voice_communication_init`` 不可同时配置为 true)
|
||||
#. 内部: 首先进行 BSS/NS 算法处理;若为双麦,随后还会进行 MISO 算法处理;
|
||||
#. AFE fetch,返回处理过的单通道音频数据和相关信息。其中会进行 AGC 非线性放大,具体增益值取决于用户对 ``afe_config_t`` 结构体的配置;若为双麦,在 AGC 之前还会进行降噪处理。(注: ``wakenet_init`` 和 ``voice_communication_init`` 不可同时配置为 true)
|
||||
|
||||
.. note::
|
||||
``afe->feed()`` 和 ``afe->fetch()`` 对用户可见, ``Internal BSS/NS/MISO Task`` 对用户不可见。
|
||||
|
||||
* AEC 在 afe->feed() 函数中运行;若 aec_init 配置为 false 状态,BSS/NS 将会在 afe->feed() 函数中运行。
|
||||
* BSS/NS/MISO 为 AFE 内部独立 Task 进行处理;
|
||||
* VAD/WakeNet 的结果,以及处理后的单通道音频,通过 afe->fetch() 函数获取。
|
||||
* AEC 在 ``afe->feed()`` 函数中运行;若 ``aec_init`` 配置为 false 状态,BSS/NS 将会在 ``afe->feed()`` 函数中运行。
|
||||
* BSS/NS/MISO 作为 AFE 内部独立 Task 进行处理。
|
||||
* VAD/WakeNet 的结果,以及处理后的单通道音频,通过 ``afe->fetch()`` 函数获取。
|
||||
|
||||
选择 AFE Handle
|
||||
~~~~~~~~~~~~~~~
|
||||
---------------
|
||||
|
||||
目前 AFE 支持单麦和双麦两种应用场景,并且可对算法模块进行灵活配置。单麦场景内部 Task 为 NS 处理,双麦场景内部 Task 为 BSS 处理,双麦场景若配置为语音通话(即: ``wakenet_init=false, voice_communication_init=true``),则会再增加一个 MISO 的内部 Task。
|
||||
目前 AFE 支持单麦和双麦配置,并且可对算法模块进行灵活配置。
|
||||
|
||||
对于AFE handle的获取,语音识别场景与语音通话场景,略有差异:
|
||||
* 单麦配置:
|
||||
* 内部 Task 由 NS 处理
|
||||
* 双麦配置:
|
||||
* 双麦场景的内部 Task 由 BSS 处理
|
||||
* 此外,如用于语音通话场景(即 ``wakenet_init=false, voice_communication_init=true``),则会再增加一个 MISO 的内部 Task。
|
||||
|
||||
- 语音识别
|
||||
获取 AFE handle 的命令如下:
|
||||
|
||||
* 语音识别场景
|
||||
|
||||
::
|
||||
|
||||
esp_afe_sr_iface_t *afe_handle = &ESP_AFE_SR_HANDLE;
|
||||
|
||||
- 语音通话
|
||||
* 语音通话场景
|
||||
|
||||
::
|
||||
|
||||
esp_afe_sr_iface_t *afe_handle = &ESP_AFE_VC_HANDLE;
|
||||
|
||||
输入音频
|
||||
~~~~~~~~
|
||||
--------
|
||||
|
||||
目前 AFE 支持单麦和双麦两种应用场景,可根据 ``afe->feed()`` 的音频,配置相应的音频通道数。修改方式:在宏 ``AFE_CONFIG_DEFAULT()`` 中对 ``pcm_config`` 结构体成员进行配置修改,其支持如下几种配置组合 (注:一定要满足 ``total_ch_num = mic_num + ref_num``):
|
||||
目前 AFE 支持单麦和双麦配置,可根据 ``afe->feed()`` 的音频,配置相应的音频通道数。
|
||||
|
||||
修改方式:在宏 ``AFE_CONFIG_DEFAULT()`` 中对 ``pcm_config`` 结构体成员进行配置修改。在配置时有如下要求:
|
||||
|
||||
1. ``total_ch_num = mic_num + ref_num``
|
||||
2. ``ref_num = 0`` 或 ``ref_num = 1`` (由于目前 AEC 仅只支持单回路)
|
||||
|
||||
几种支持的配置组合如下:
|
||||
|
||||
几种支持的配置组合如下:
|
||||
|
||||
::
|
||||
|
||||
@ -92,77 +101,70 @@ Audio Front-end 框架
|
||||
total_ch_num=2, mic_num=2, ref_num=0
|
||||
total_ch_num=3, mic_num=2, ref_num=1
|
||||
|
||||
(注解: total_ch_num: 总通道数,mic_num: 麦克风通道数,ref_num: 参考回路通道数)
|
||||
其中,
|
||||
* ``total_ch_num``:总通道数
|
||||
* ``mic_num``:麦克风通道数
|
||||
* ``ref_num``:参考回路通道数
|
||||
|
||||
对于 AEC,目前只支持单回路,故 ref_num 的值只能为 0 或 1
|
||||
|
||||
- AFE 单麦场景
|
||||
AFE 单麦场景
|
||||
^^^^^^^^^^^^
|
||||
* 输入音频格式为 16 KHz,16 bit,双通道(1 个通道为 mic 数据,另一个通道为参考回路)。注意,若不需要 AEC,则可只包含 1 个通道 mic 数据,而无需包含参考回路(即 ``ref_num = 0``)。
|
||||
* 输入数据帧长,会根据用户配置的算法模块不同而有差异, 用户可以使用 ``afe->get_feed_chunksize`` 来获取需要的采样点数目(采样点数据类型为 int16)
|
||||
|
||||
- 输入音频格式为 16KHz, 16bit, 双通道 (1个通道为 mic 数据,另一个通道为参考回路) ; 若不需要 AEC,音频不包含参考回路,则可只包含1个通道 mic 数据,ref_num 设置为0。
|
||||
- 输入数据帧长,会根据用户配置的算法模块不同而有差异, 用户可以使用 ``afe->get_feed_chunksize`` 来获取需要的采样点数目(采样点数据类型为 int16)
|
||||
数据排布示意如下:
|
||||
|
||||
数据排布如下:
|
||||
.. figure:: ../../_static/AFE_mode_0.png
|
||||
:alt: input data of single MIC
|
||||
:height: 1.2in
|
||||
|
||||
.. figure:: ../../_static/AFE_mode_0.png
|
||||
:alt: input data of single MIC
|
||||
:height: 0.7in
|
||||
AFE 双麦场景
|
||||
^^^^^^^^^^^^
|
||||
* 输入音频格式为 16 KHz,16 bit,三通道(2 个通道为 mic 数据,另一个通道为参考回路)。注意,若不需要 AEC,则可只包含 2 个通道 mic 数据,而无需包含参考回路(即 ``ref_num = 0``)。
|
||||
* 输入数据帧长,会根据用户配置的算法模块不同而有差异,用户可以使用 ``afe->get_feed_chunksize`` 来获取需要填充的数据量
|
||||
|
||||
- AFE 双麦场景
|
||||
数据排布示意如下:
|
||||
|
||||
- 输入音频格式为 16KHz, 16bit, 三通道;若不需要 AEC,音频不包含参考回路,则可只包含两个通道 mic 数据,ref_num 设置为0。
|
||||
- 输入数据帧长,会根据用户配置的算法模块不同而有差异,用户可以使用 ``afe->get_feed_chunksize`` 来获取需要填充的数据量
|
||||
.. figure:: ../../_static/AFE_mode_other.png
|
||||
:alt: input data of dual MIC
|
||||
:height: 0.75in
|
||||
|
||||
数据排布如下:
|
||||
|
||||
.. figure:: ../../_static/AFE_mode_other.png
|
||||
:alt: input data of dual MIC
|
||||
:height: 0.75in
|
||||
|
||||
注意:换算成数据量大小为: ``afe->get_feed_chunksize * 通道数 * sizeof(short)``
|
||||
这里,数据量 = ``afe->get_feed_chunksize * 通道数 * sizeof(short)``
|
||||
|
||||
AEC 简介
|
||||
~~~~~~~~
|
||||
|
||||
AEC (Acoustic Echo Cancellation) 算法最多支持双麦处理,能够有效的去除 mic 输入信号中的自身播放声音。从而可以在自身播放音乐的情况下进行很好的语音识别等应用。
|
||||
""""""""
|
||||
AEC (Acoustic Echo Cancellation) 算法最多支持双麦处理,能够有效的去除 mic 输入信号中的自身播放声音,从而可以在自身播放音乐的情况下很好的完成语音识别。
|
||||
|
||||
NS 简介
|
||||
~~~~~~~
|
||||
|
||||
NS (Noise Suppression)
|
||||
算法支持单通道处理,能够对单通道音频中的非人声噪声进行抑制,尤其针对稳态噪声,具有很好的抑制效果。
|
||||
"""""""
|
||||
NS (Noise Suppression) 算法支持单通道处理,能够对单通道音频中的非人声噪声进行抑制,尤其针对稳态噪声,具有很好的抑制效果。
|
||||
|
||||
BSS 简介
|
||||
~~~~~~~~
|
||||
|
||||
BSS (Blind Source Separation)
|
||||
算法支持双通道处理,能够很好的将目标声源和其余干扰音进行盲源分离,从而提取出有用音频信号,保证了后级语音的质量。
|
||||
""""""""
|
||||
BSS (Blind Source Separation) 算法支持双通道处理,能够很好的将目标声源和其余干扰音进行盲源分离,从而提取出有用音频信号,保证了后级语音的质量。
|
||||
|
||||
MISO 简介
|
||||
~~~~~~~~~
|
||||
|
||||
MISO (Multi Input Single Output)
|
||||
算法支持双通道输入,单通道输出。用于在双麦场景,没有唤醒使能的情况下,选择信噪比高的一路音频输出。
|
||||
"""""""""
|
||||
MISO (Multi Input Single Output) 算法支持双通道输入,单通道输出。用于在双麦场景,没有唤醒使能的情况下,选择信噪比高的一路音频输出。
|
||||
|
||||
VAD 简介
|
||||
~~~~~~~~
|
||||
|
||||
""""""""
|
||||
VAD (Voice Activity Detection) 算法支持实时输出当前帧的语音活动状态。
|
||||
|
||||
AGC 简介
|
||||
~~~~~~~~
|
||||
""""""""
|
||||
AGC (Automatic Gain Control) 动态调整输出音频的幅值,当弱信号输入时,放大输出幅度;当输入信号达到一定强度时,压缩输出幅度。
|
||||
|
||||
AGC (Automatic Gain Control)
|
||||
动态调整输出音频的幅值,当弱信号输入时,放大输出幅度;当输入信号达到一定强度时,压缩输出幅度。
|
||||
|
||||
WakeNet or Bypass 简介
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
用户可以选择是否在 AFE 中进行唤醒词的识别。当用户调用 ``afe->disable_wakenet(afe_data)`` 后,则进入 Bypass 模式,AFE 模块不会进行唤醒词的识别。
|
||||
WakeNet 或 Bypass 简介
|
||||
""""""""""""""""""""""
|
||||
用户可以选择是否在 AFE 中进行唤醒词的识别。当用户调用 ``afe->disable_wakenet(afe_data)`` 后,则进入 Bypass 模式,此时 AFE 模块不会进行唤醒词的识别。
|
||||
|
||||
输出音频
|
||||
~~~~~~~~
|
||||
--------
|
||||
|
||||
AFE 的输出音频为单通道数据。在语音识别场景,若WakeNet 开启的情况下,AFE 会输出有目标人声的单通道数据。在语音通话场景,将会输出信噪比更高的单通道数据。
|
||||
AFE 的输出音频为单通道数据。
|
||||
* 语音识别场景:在 WakeNet 开启的情况下,输出有目标人声的单通道数据
|
||||
* 语音通话场景:输出信噪比更高的单通道数据
|
||||
|
||||
.. only:: html
|
||||
|
||||
@ -170,24 +172,24 @@ AFE 的输出音频为单通道数据。在语音识别场景,若WakeNet 开
|
||||
--------
|
||||
|
||||
定义 afe_handle
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
``afe_handle`` 是用户后续调用 afe 接口的函数句柄。所以第一步需先获得 ``afe_handle``。
|
||||
|
||||
- 语音识别
|
||||
- 语音识别
|
||||
|
||||
::
|
||||
|
||||
esp_afe_sr_iface_t *afe_handle = &ESP_AFE_SR_HANDLE;
|
||||
|
||||
- 语音通话
|
||||
- 语音通话
|
||||
|
||||
::
|
||||
|
||||
esp_afe_sr_iface_t *afe_handle = &ESP_AFE_VC_HANDLE;
|
||||
|
||||
配置 afe
|
||||
~~~~~~~~~~~
|
||||
^^^^^^^^
|
||||
|
||||
获取 afe 的配置:
|
||||
|
||||
@ -195,95 +197,86 @@ AFE 的输出音频为单通道数据。在语音识别场景,若WakeNet 开
|
||||
|
||||
afe_config_t afe_config = AFE_CONFIG_DEFAULT();
|
||||
|
||||
可调整 ``afe_config`` 中各算法模块的使能及其相应参数:
|
||||
其中,``afe_config`` 中各算法模块的使能及其相应参数可以单独调整:
|
||||
|
||||
::
|
||||
|
||||
#define AFE_CONFIG_DEFAULT() { \
|
||||
// 配置是否使能 AEC
|
||||
.aec_init = true, \
|
||||
// 配置是否使能 BSS/NS
|
||||
.se_init = true, \
|
||||
// 配置是否使能 VAD(仅用于语音识别场景)
|
||||
.vad_init = true, \
|
||||
// 配置是否使能唤
|
||||
.wakenet_init = true, \
|
||||
// 配置是否使能语音通话(不可与 wakenet_init 同时使能)
|
||||
.voice_communication_init = false, \
|
||||
// 配置是否使能语音通话中 AGC
|
||||
.voice_communication_agc_init = false, \
|
||||
// 配置 AGC 的增益值(单位为 dB)
|
||||
.voice_communication_agc_gain = 15, \
|
||||
// 配置 VAD 检测的操作模式,越大越激进
|
||||
.vad_mode = VAD_MODE_3, \
|
||||
//
|
||||
.wakenet_model_name = NULL, \
|
||||
// 配置唤醒模式(对应为多少通道的唤醒,根据mic通道的数量选择)
|
||||
.wakenet_mode = DET_MODE_2CH_90, \
|
||||
// 配置 AFE 工作模式(SR_MODE_LOW_COST 或 SR_MODE_HIGH_PERF)
|
||||
.afe_mode = SR_MODE_LOW_COST, \
|
||||
// 配置运行 AFE 内部 BSS/NS/MISO 算法的 CPU 核
|
||||
.afe_perferred_core = 0, \
|
||||
// 配置运行 AFE 内部 BSS/NS/MISO 算法的 task 优先级
|
||||
.afe_perferred_priority = 5, \
|
||||
// 配置内部 ringbuf
|
||||
.afe_ringbuf_size = 50, \
|
||||
// 配置内存分配模式,详见下方描述
|
||||
.memory_alloc_mode = AFE_MEMORY_ALLOC_MORE_PSRAM, \
|
||||
// 配置音频线性放大 Level,详见下方描述
|
||||
.agc_mode = AFE_MN_PEAK_AGC_MODE_2, \
|
||||
// 配置音频总的通道数
|
||||
.pcm_config.total_ch_num = 3, \
|
||||
// 配置音频麦克风的通道数
|
||||
.pcm_config.mic_num = 2, \
|
||||
// 配置音频参考回路通道数
|
||||
.pcm_config.ref_num = 1, \
|
||||
}
|
||||
|
||||
- aec_init: AEC 算法是否使能。
|
||||
|
||||
- se_init: BSS/NS 算法是否使能。
|
||||
|
||||
- vad_init: VAD 是否使能 ( 仅可在语音识别场景中使用 )
|
||||
|
||||
- wakenet_init: 唤醒是否使能。
|
||||
|
||||
- voice_communication_init: 语音通话是否使能。与 wakenet_init
|
||||
不能同时使能。
|
||||
|
||||
- voice_communication_agc_init: 语音通话中AGC是否使能。
|
||||
|
||||
- voice_communication_agc_gain: AGC的增益值,单位为dB。
|
||||
|
||||
- vad_mode: VAD 检测的操作模式,越大越激进。
|
||||
|
||||
- wakenet_model_name: 宏 ``AFE_CONFIG_DEFAULT()`` 中该值默认为NULL。使用 ``idf.py menuconfig`` 选择了相应的唤醒模型后,在调用 ``afe_handle->create_from_config`` 之前,需给该处赋值具体的模型名字,类型为字符串形式。唤醒模型的具体说明,详见: `flash_model <../flash_model/README_cn.md>`__ (注意:示例代码中,使用了 esp_srmodel_filter() 获取模型名字,若 menuconfig 中选择了多个模型共存,该函数将会随机返回一个模型名字)
|
||||
|
||||
- wakenet_mode: 唤醒的模式。对应为多少通道的唤醒,根据mic通道的数量选择
|
||||
|
||||
- afe_mode: 乐鑫 AFE 目前支持 2 种工作模式,分别为:SR_MODE_LOW_COST,SR_MODE_HIGH_PERF。详细可见 afe_sr_mode_t 枚举。
|
||||
|
||||
- wakenet_model_name: 宏 ``AFE_CONFIG_DEFAULT()`` 中该值默认为 NULL。使用 ``idf.py menuconfig`` 选择了相应的唤醒模型后,在调用 ``afe_handle->create_from_config`` 之前,需给该处赋值具体的模型名字,类型为字符串形式。唤醒模型的具体说明,详见::doc:`flash_model <../flash_model/README>` (注意:示例代码中,使用了 ``esp_srmodel_filter()`` 获取模型名字,若 ``menuconfig`` 中选择了多个模型共存,该函数将会随机返回一个模型名字)
|
||||
- afe_mode: 乐鑫 AFE 目前支持 2 种工作模式,分别为: ``SR_MODE_LOW_COS`` 和 ``SR_MODE_HIGH_PERF``。详细可见 ``afe_sr_mode_t`` 枚举。
|
||||
- SR_MODE_LOW_COST: 量化版本,占用资源较少。
|
||||
|
||||
- SR_MODE_HIGH_PERF: 非量化版本,占用资源较多。
|
||||
|
||||
**ESP32 芯片,只支持模式 SR_MODE_HIGH_PERF; ESP32S3 芯片,两种模式均支持**
|
||||
|
||||
- afe_perferred_core: AFE 内部 BSS/NS/MISO 算法,运行在哪个 CPU 核。
|
||||
|
||||
- afe_perferred_priority: AFE 内部 BSS/NS/MISO 算法,运行的task优先级。
|
||||
|
||||
- afe_ringbuf_size: 内部 ringbuf 大小的配置。
|
||||
.. note::
|
||||
ESP32 芯片,只支持 ``SR_MODE_HIGH_PERF`` 模式;ESP32-S3 芯片,两种模式均支持。
|
||||
|
||||
- memory_alloc_mode: 内存分配的模式。可配置三个值:
|
||||
- AFE_MEMORY_ALLOC_MORE_INTERNAL:更多的从内部ram分配。
|
||||
|
||||
- AFE_MEMORY_ALLOC_MORE_INTERNAL: 更多的从内部ram分配。
|
||||
- AFE_MEMORY_ALLOC_INTERNAL_PSRAM_BALANCE:部分从内部ram分配。
|
||||
|
||||
- AFE_MEMORY_ALLOC_INTERNAL_PSRAM_BALANCE: 部分从内部ram分配。
|
||||
|
||||
- AFE_MEMORY_ALLOC_MORE_PSRAM: 绝大部分从外部psram分配
|
||||
- AFE_MEMORY_ALLOC_MORE_PSRAM:绝大部分从外部psram分配
|
||||
|
||||
- agc_mode: 将音频线性放大的 level 配置,该配置在语音识别场景下起作用,并且在唤醒使能时才生效。可配置四个值:
|
||||
|
||||
- AFE_MN_PEAK_AGC_MODE_1: 线性放大喂给后续multinet的音频,峰值处为 -5dB。
|
||||
- AFE_MN_PEAK_AGC_MODE_1:线性放大喂给后续multinet的音频,峰值处为 -5 dB。
|
||||
|
||||
- AFE_MN_PEAK_AGC_MODE_2: 线性放大喂给后续multinet的音频,峰值处为 -4dB。
|
||||
- AFE_MN_PEAK_AGC_MODE_2:线性放大喂给后续multinet的音频,峰值处为 -4 dB。
|
||||
|
||||
- AFE_MN_PEAK_AGC_MODE_3: 线性放大喂给后续multinet的音频,峰值处为 -3dB。
|
||||
- AFE_MN_PEAK_AGC_MODE_3:线性放大喂给后续multinet的音频,峰值处为 -3 dB。
|
||||
|
||||
- AFE_MN_PEAK_NO_AGC: 不做线性放大
|
||||
- AFE_MN_PEAK_NO_AGC:不做线性放大
|
||||
|
||||
- pcm_config: 根据 ``afe->feed()`` 喂入的音频结构进行配置,该结构体有三个成员变量需要配置:
|
||||
|
||||
- total_ch_num: 音频总的通道数,total_ch_num = mic_num + ref_num。
|
||||
- total_ch_num:音频总的通道数, ``total_ch_num = mic_num + ref_num``。
|
||||
|
||||
- mic_num: 音频的麦克风通道数。目前仅支持配置为 1 或 2。
|
||||
|
||||
- ref_num: 音频的参考回路通道数,目前仅支持配置为 0 或 1。
|
||||
|
||||
创建 afe_data
|
||||
~~~~~~~~~~~~~~~~
|
||||
"""""""""""""
|
||||
|
||||
用户使用 ``afe_handle->create_from_config(&afe_config)`` 函数来获得数据句柄,这将会在afe内部使用,传入的参数即为上面第2步中获得的配置。
|
||||
|
||||
@ -291,14 +284,14 @@ AFE 的输出音频为单通道数据。在语音识别场景,若WakeNet 开
|
||||
|
||||
/**
|
||||
* @brief Function to initialze a AFE_SR instance
|
||||
*
|
||||
*
|
||||
* @param afe_config The config of AFE_SR
|
||||
* @returns Handle to the AFE_SR data
|
||||
*/
|
||||
typedef esp_afe_sr_data_t* (*esp_afe_sr_iface_op_create_from_config_t)(afe_config_t *afe_config);
|
||||
|
||||
feed 音频数据
|
||||
~~~~~~~~~~~~~~~~
|
||||
"""""""""""""
|
||||
|
||||
在初始化 AFE 完成后,用户需要将音频数据使用 ``afe_handle->feed()`` 函数输入到 AFE 中进行处理。
|
||||
|
||||
@ -313,14 +306,15 @@ AFE 的输出音频为单通道数据。在语音识别场景,若WakeNet 开
|
||||
* The last channel is reference signal if it has reference data.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
*
|
||||
* @param in The input microphone signal, only support signed 16-bit @ 16 KHZ. The frame size can be queried by the
|
||||
*
|
||||
* @param in The input microphone signal, only support signed 16-bit @ 16 KHZ. The frame size can be queried by the
|
||||
* `get_feed_chunksize`.
|
||||
* @return The size of input
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_feed_t)(esp_afe_sr_data_t *afe, const int16_t* in);
|
||||
|
||||
获取音频通道数:
|
||||
获取音频通道数
|
||||
""""""""""""""
|
||||
|
||||
使用 ``afe_handle->get_total_channel_num()`` 函数可以获取需要传入 ``afe_handle->feed()`` 函数的总数据通道数。其返回值等于AFE_CONFIG_DEFAULT()中配置的 ``pcm_config.mic_num + pcm_config.ref_num``
|
||||
|
||||
@ -328,14 +322,14 @@ AFE 的输出音频为单通道数据。在语音识别场景,若WakeNet 开
|
||||
|
||||
/**
|
||||
* @brief Get the total channel number which be config
|
||||
*
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The amount of total channels
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_get_total_channel_num_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
fetch 音频数据
|
||||
~~~~~~~~~~~~~~
|
||||
"""""""""""""""
|
||||
|
||||
用户调用 ``afe_handle->fetch()`` 函数可以获取处理完成的单通道音频以及相关处理信息。
|
||||
|
||||
@ -389,23 +383,23 @@ AFE 的输出音频为单通道数据。在语音识别场景,若WakeNet 开
|
||||
} afe_fetch_result_t;
|
||||
|
||||
WakeNet 使用
|
||||
~~~~~~~~~~~~~
|
||||
""""""""""""
|
||||
|
||||
当用户在唤醒后需要进行其他操作,比如离线或在线语音识别,这时候可以暂停 WakeNet 的运行,从而减轻 CPU 的资源消耗。
|
||||
|
||||
用户可以调用 ``afe_handle->disable_wakenet(afe_data)`` 来停止 WakeNet。当后续应用结束后又可以调用 ``afe_handle->enable_wakenet(afe_data)`` 来开启 WakeNet。
|
||||
|
||||
另外,ESP32S3 芯片,支持唤醒词切换。(注: ESP32 芯片只支持一个唤醒词,不支持切换)。在初始化 AFE 完成后,ESP32S3 芯片可通过 ``set_wakenet()`` 函数切换唤醒词。例如, ``afe_handle->set_wakenet(afe_data, “wn9_hilexin”)`` 切换到“Hi Lexin”唤醒词。具体如何配置多个唤醒词,详见: `flash_model <../flash_model/README_CN.md>`__
|
||||
另外,ESP32-S3 芯片还可支持唤醒词切换。(ESP32 芯片只支持一个唤醒词,不支持切换)。在初始化 AFE 完成后,ESP32-S3 芯片可通过 ``set_wakenet()`` 函数切换唤醒词。例如, ``afe_handle->set_wakenet(afe_data, “wn9_hilexin”)`` 切换到 “Hi Lexin” 唤醒词。具体如何配置多个唤醒词,详见: :doc:`flash_model <../flash_model/README>`。
|
||||
|
||||
AEC 使用
|
||||
~~~~~~~~
|
||||
--------
|
||||
|
||||
AEC 的使用和 WakeNet 相似,用户可以根据自己的需求来停止或开启 AEC。
|
||||
|
||||
- 停止 AEC
|
||||
|
||||
afe->disable_aec(afe_data);
|
||||
``afe->disable_aec(afe_data);``
|
||||
|
||||
- 开启 AEC
|
||||
|
||||
afe->enable_aec(afe_data);
|
||||
``afe->enable_aec(afe_data);``
|
||||
|
||||
@ -58,7 +58,7 @@ Use Wakenet
|
||||
|
||||
**注:多唤醒词选项只支持 ESP32S3,具体根据客户硬件flash容量,选择合适数量的唤醒词。**
|
||||
|
||||
更多细节请参考 `WakeNet <../wake_word_engine/README.rst>`__ 。
|
||||
更多细节请参考 :doc:`WakeNet <../wake_word_engine/README>` 。
|
||||
|
||||
Use Multinet
|
||||
~~~~~~~~~~~~~
|
||||
@ -104,12 +104,12 @@ ESP32S3 支持:
|
||||
|
||||
当用户在 ``English Speech Commands Model`` 中选择非 ``None`` 时,需要在该项处添加中文命令词。
|
||||
|
||||
用户按照需求自定义添加命令词,具体请参考 `MultiNet <../speech_command_recognition/README.md>`__ 。
|
||||
用户按照需求自定义添加命令词,具体请参考 :doc:`MultiNet <../speech_command_recognition/README>` 。
|
||||
|
||||
模型使用
|
||||
---------
|
||||
|
||||
当用户完成以上的配置选择后,应用层请参考 esp-skainet 进行初始化和使用。这里介绍一下模型数据加载在用户工程中的代码实现。 也可以参考代码 `model_path.c <../../src/model_path.c>`__
|
||||
当用户完成以上的配置选择后,应用层请参考 esp-skainet 进行初始化和使用。这里介绍一下模型数据加载在用户工程中的代码实现。 也可以参考代码 `model_path.c <../src/model_path.c>`_ 。
|
||||
|
||||
使用 ESP32
|
||||
~~~~~~~~~~
|
||||
@ -183,7 +183,7 @@ ESP32S3 支持:
|
||||
|
||||
//
|
||||
// step1: initialize spiffs and return models in spiffs
|
||||
//
|
||||
//
|
||||
srmodel_list_t *models = esp_srmodel_init();
|
||||
|
||||
//
|
||||
@ -196,7 +196,7 @@ ESP32S3 支持:
|
||||
char *cn_mn_name = esp_srmodel_filter(models, ESP_MN_PREFIX, ESP_MN_CHINESE); // select english multinet model
|
||||
|
||||
// It also works if you use the model name directly in your code.
|
||||
char *my_wn_name = "wn9_hilexin"
|
||||
char *my_wn_name = "wn9_hilexin"
|
||||
// we recommend you to check that it is loaded correctly
|
||||
if (!esp_srmodel_exists(models, my_wn_name))
|
||||
printf("%s can not be loaded correctly\n")
|
||||
|
||||
@ -3,46 +3,48 @@ ESP-SR 用户指南
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
||||
这里是乐鑫 `ESP-SR <https://github.com/espressif/esp-sr>`__ 本文档旨在指导用户基于 ESP32 系列芯片为基础搭建 AI 语音解决方案,将通过一个简单的示例展示如何使用ESP-SR中的算法和模型。
|
||||
乐鑫 `ESP-SR <https://github.com/espressif/esp-sr>`__ 可以帮助用户基于 ESP32 系列芯片或 ESP32-S3 系列芯片,搭建 AI 语音解决方案。本文档将通过一个简单的示例,展示如何使用 ESP-SR 中的算法和模型。
|
||||
|
||||
概述
|
||||
----
|
||||
|
||||
ESP-SR 支持以下模块:
|
||||
|
||||
* `声学前端算法 <audio_front_end/README.md>`__
|
||||
* `唤醒词检测 <wake_word_engine/README.md>`__
|
||||
* `唤醒词检测 <speech_command_recognition/README>`__
|
||||
* 语音合成 (目前只支持中文)
|
||||
* :doc:`声学前端算法 <audio_front_end/README>`
|
||||
* :doc:`唤醒词检测 <wake_word_engine/README>`
|
||||
* :doc:`命令词识别 <speech_command_recognition/README>`
|
||||
* 语音合成(目前只支持中文)
|
||||
|
||||
准备工作
|
||||
--------
|
||||
|
||||
硬件:
|
||||
~~~~~~
|
||||
必备硬件
|
||||
~~~~~~~~
|
||||
|
||||
* 一款音频开发版,推荐使用 ESP32-S3-Korvo-1 或者 ESP32-S3-Korvo-2
|
||||
* **USB 数据线** (A 转 Micro-B)
|
||||
* 电脑 (Linux)
|
||||
* 一款音频开发版,推荐使用 ESP32-S3-Korvo-1 或者 ESP32-S3-Korvo-2
|
||||
* USB 2.0 数据线(标准 A 型转 Micro-B 型)
|
||||
* 电脑(Linux)
|
||||
|
||||
.. note:: 目前一些开发板使用的是 USB Type C 接口。请确保使用合适的数据线连接开发板!
|
||||
.. note::
|
||||
目前一些开发板使用的是 USB Type C 接口。请确保使用合适的数据线连接开发板!
|
||||
|
||||
软件:
|
||||
~~~~~~
|
||||
必备软件
|
||||
~~~~~~~~
|
||||
|
||||
* 下载 `ESP-SKAINET <https://github.com/espressif/esp-skainet>`,ESP-SR 将作为 ESP-SKAINET 的组件被一起下载。
|
||||
* 配置安装 ESP-IDF,推荐使用 ESP-SKAINET 中包含的版本。安装方法请参考 `ESP-IDF 快速入门 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/get-started/index.html>`。
|
||||
* 下载 `ESP-SKAINET <https://github.com/espressif/esp-skainet>`__,ESP-SR 将作为 ESP-SKAINET 的组件被一起下载。
|
||||
* 配置安装 ESP-IDF,推荐使用 ESP-SKAINET 中包含的版本。安装方法请参考 `ESP-IDF 编程指南 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32s3/index.html>`__ 中的 `快速入门 <https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32s3/get-started/index.html>`__ 小节。
|
||||
|
||||
|
||||
编译运行一个示例
|
||||
----------------
|
||||
|
||||
* 进入 ESP-SKAINET/examples/cn_speech_commands_recognition 目录。
|
||||
* 参考该示例目录下的配置和编译说明,运行该示例。
|
||||
* 该示例为中文命令指令识别示例,通过说唤醒词(Hi,乐鑫),触发语音指令识别。当一段时间没有语音指令后,会关闭语音指令识别,并等待下一次唤醒词触发。
|
||||
|
||||
* 进入 `ESP-SKAINET/examples/cn_speech_commands_recognition <https://github.com/espressif/esp-skainet/tree/master/examples/cn_speech_commands_recognition>`__ 目录。
|
||||
* 参考该示例目录下的配置和编译说明,运行该示例。
|
||||
* 该示例为中文命令指令识别示例,通过说唤醒词(Hi,乐鑫),触发语音指令识别。注意,当一段时间没有语音指令后,语音指令识别功能将关闭,并等待下一次唤醒词触发。
|
||||
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
:hidden:
|
||||
|
||||
AFE 声学前端算法 <audio_front_end/README>
|
||||
唤醒词模型 <wake_word_engine/README>
|
||||
|
||||
@ -32,7 +32,7 @@ MultiNet 输入为经过前端语音算法(AFE)处理过的音频,格式
|
||||
| English | | | | √ |
|
||||
+---------+-----------+-------------+---------------+-------------+
|
||||
|
||||
用户选择不同的模型的方法请参考 `flash model <../flash_model/README_CN.md>`__ 。
|
||||
用户选择不同的模型的方法请参考 :doc:`flash model <../flash_model/README>` 。
|
||||
|
||||
**注:其中以 ``Q8`` 结尾的模型代表模型的 8bit 版本,表明该模型更加轻量化。**
|
||||
|
||||
@ -83,7 +83,7 @@ MultiNet 对命令词自定义方法没有限制,用户可以通过任意方
|
||||
|
||||
英文命令词需要使用特定音标表示,每个单词的音标间用空格隔开,比如“turn on the light”,需要写成“TkN nN jc LiT”。
|
||||
|
||||
**并且我们也提供相应的工具,供用户将汉字转换为拼音,详细可见:** `英文转音素工具 <../../tool/multinet_g2p.py>`__。
|
||||
此外,我们也提供相应的工具,供用户将汉字转换为拼音,详细可见: `英文转音素工具 <../../tool/multinet_g2p.py>` 。
|
||||
|
||||
.. only:: latex
|
||||
|
||||
@ -138,14 +138,14 @@ MultiNet 支持多种且灵活的命令词设置方式,用户无论通过那
|
||||
|
||||
MultiNet 支持在运行过程中在线动态添加/删除/修改命令词,该过程无须更换模型和调整参数。具体可以参考 ESP-Skainet 中 example。
|
||||
|
||||
具体API说明请参考 `esp_mn_speech_commands <../../src/esp_mn_speech_commands.c>`__ :
|
||||
具体 API 说明请参考 `esp_mn_speech_commands <../../src/esp_mn_speech_commands.c>`_。
|
||||
|
||||
运行命令词识别
|
||||
--------------
|
||||
|
||||
命令词识别需要和 ESP-SR 中的声学算法模块(AFE)(AFE中需使能唤醒(WakeNet))一起运行。关于 AFE 的使用,请参考文档:
|
||||
|
||||
`AFE 介绍及使用 <../audio_front_end/README_CN.md>`__
|
||||
:doc:`AFE 介绍及使用 <../audio_front_end/README>`
|
||||
|
||||
当用户配置完成 AFE 后,请按照以下步骤配置和运行 MultiNet:
|
||||
|
||||
@ -153,7 +153,7 @@ MultiNet 初始化
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
- 模型加载与初始化
|
||||
请参考 `flash_model <../flash_model/README_CN.md>`__
|
||||
请参考 :doc:`flash_model <../flash_model/README>`
|
||||
|
||||
- 设置命令词 请参考上文 #3。
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
乐鑫提供 离线语音唤醒词 定制服务,详情如下:
|
||||
|
||||
#. “HI乐鑫“,”你好小鑫” 等官方公开的唤醒词,客户可直接商用
|
||||
#. “HI乐鑫”,“你好小鑫” 等官方公开的唤醒词,客户可直接商用
|
||||
|
||||
- 如 ADF/ASR Demo 提供的离线命令词,同时乐鑫会逐渐开放更多的商用 Free 关键词
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
|
||||
- 对于各类语音音箱类设计,乐鑫可提供 原理图/PCB 等设计参考,客户可以根据自身具体需求设计修改,设计完毕后,乐鑫可提供Review服务,避免常见设计问题。
|
||||
|
||||
- 腔体结构,最好有专门的声学人员参与设计,乐鑫不提供 ID 设计类的参考,客户可以市场上主流音箱设计为参考
|
||||
- 腔体结构,最好有专门的声学人员参与设计,乐鑫不提供 ID 设计类的参考,客户可以市场上主流音箱设计为参考
|
||||
- 例如:天猫精灵、小度音箱、谷歌音箱等
|
||||
|
||||
#. 硬件设计好后,客户可通过以下简单测试,验证硬件设计效果(下列测试都是基于语音室环境,客户可以根据自身测试环境做调整)
|
||||
|
||||
@ -75,13 +75,13 @@ WakeNet使用
|
||||
|
||||
- WakeNet 模型选择
|
||||
|
||||
WakeNet 模型选择请参考 `flash model 介绍 <../flash_model/README_CN.md>`__ 。
|
||||
WakeNet 模型选择请参考 :doc:`flash model 介绍 <../flash_model/README>` 。
|
||||
|
||||
自定义的唤醒词,请参考 `乐鑫语音唤醒词定制流程 <乐鑫语音唤醒词定制流程.md>`__ 。
|
||||
自定义的唤醒词,请参考 :doc:`乐鑫语音唤醒词定制流程 <ESP_Wake_Words_Customization>` 。
|
||||
|
||||
- WakeNet 运行
|
||||
|
||||
WakeNet 目前包含在语音前端算法 `AFE <../audio_front_end/README_CN.md>`__ 中,默认为运行状态,并将识别结果通过 AFE fetch 接口返回。
|
||||
WakeNet 目前包含在语音前端算法 :doc:`AFE <../audio_front_end/README>` 中,默认为运行状态,并将识别结果通过 AFE fetch 接口返回。
|
||||
|
||||
如果用户不需要初始化 WakeNet,请在 AFE 配置时选择:
|
||||
|
||||
@ -99,9 +99,9 @@ WakeNet使用
|
||||
性能测试
|
||||
--------
|
||||
|
||||
具体请参考 `Performance Test <../benchmark/README.md>`__ 。
|
||||
具体请参考 :doc:`Performance Test <../benchmark/README>` 。
|
||||
|
||||
唤醒词定制
|
||||
----------
|
||||
|
||||
如果需要定制唤醒词,请参考 `乐鑫语音唤醒词定制流程 <乐鑫语音唤醒词定制流程.md>`__ 。
|
||||
如果需要定制唤醒词,请参考 :doc:`乐鑫语音唤醒词定制流程 <ESP_Wake_Words_Customization>` 。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user