mirror of
https://github.com/espressif/esp-sr.git
synced 2025-09-15 15:28:44 +08:00
feat(mn): Add multinet5q8 Chinese model
This commit is contained in:
parent
15132edf68
commit
59024d2ae7
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,10 @@
|
||||
#define ESP_MN_MAX_PHRASE_LEN 63
|
||||
#define ESP_MN_MIN_PHRASE_LEN 2
|
||||
|
||||
#define ESP_MN_PREFIX "mn"
|
||||
#define ESP_MN_ENGLISH "en"
|
||||
#define ESP_MN_CHINESE "cn"
|
||||
|
||||
typedef enum {
|
||||
ESP_MN_STATE_DETECTING = 0, // detecting
|
||||
ESP_MN_STATE_DETECTED = 1, // detected
|
||||
@ -84,6 +88,14 @@ typedef int (*esp_mn_iface_op_set_det_threshold_t)(model_iface_data_t *model, fl
|
||||
*/
|
||||
typedef int (*esp_mn_iface_op_get_samp_rate_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get the language of model
|
||||
*
|
||||
* @param model The language name
|
||||
* @return Language name string defined in esp_mn_models.h, eg: ESP_MN_CHINESE, ESP_MN_ENGLISH
|
||||
*/
|
||||
typedef char * (*esp_mn_iface_op_get_language_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Feed samples of an audio stream to the speech recognition model and detect if there is a speech command found.
|
||||
*
|
||||
@ -133,6 +145,7 @@ typedef struct {
|
||||
esp_mn_iface_op_get_samp_chunksize_t get_samp_chunksize;
|
||||
esp_mn_iface_op_get_samp_chunknum_t get_samp_chunknum;
|
||||
esp_mn_iface_op_set_det_threshold_t set_det_threshold;
|
||||
esp_mn_iface_op_get_language_t get_language;
|
||||
esp_mn_iface_op_detect_t detect;
|
||||
esp_mn_iface_op_destroy_t destroy;
|
||||
esp_mn_iface_op_get_results_t get_results;
|
||||
|
||||
@ -5,11 +5,6 @@
|
||||
//a specific phrase or word.
|
||||
|
||||
|
||||
|
||||
#define ESP_MN_PREFIX "mn"
|
||||
#define ESP_MN_ENGLISH "en"
|
||||
#define ESP_MN_CHINESE "cn"
|
||||
|
||||
/**
|
||||
* @brief Get the multinet handle from model name
|
||||
*
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -64,6 +64,8 @@ elif "CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION_QUANT8" in MN_STRING:
|
||||
multinet_model.append('mn4q8_cn')
|
||||
elif "CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION" in MN_STRING and len(multinet_model) < 2:
|
||||
multinet_model.append('mn4_cn')
|
||||
elif "CONFIG_SR_MN_CN_MULTINET5_RECOGNITION_QUANT8" in MN_STRING and len(multinet_model) < 2:
|
||||
multinet_model.append('mn5q8_cn')
|
||||
|
||||
if "CONFIG_SR_MN_EN_MULTINET5_SINGLE_RECOGNITION_QUANT8" in MN_STRING and len(multinet_model) < 2:
|
||||
multinet_model.append('mn5q8_en')
|
||||
|
||||
2
model/multinet_model/mn5q8_cn/_MODEL_INFO_
Normal file
2
model/multinet_model/mn5q8_cn/_MODEL_INFO_
Normal file
@ -0,0 +1,2 @@
|
||||
# (neural network type)_(model data version)_(lable1_detection windown length_threshold for 90%_threshold for 95%)_(lable2 ...)_...
|
||||
MN5Q8_v2_chinese_8_0.9_0.90
|
||||
BIN
model/multinet_model/mn5q8_cn/mn5q8_data
Normal file
BIN
model/multinet_model/mn5q8_cn/mn5q8_data
Normal file
Binary file not shown.
BIN
model/multinet_model/mn5q8_cn/mn5q8_index
Normal file
BIN
model/multinet_model/mn5q8_cn/mn5q8_index
Normal file
Binary file not shown.
@ -54,8 +54,7 @@ void check_chip_config(void)
|
||||
|
||||
char *get_id_name_cn(int i)
|
||||
{
|
||||
#if defined CONFIG_USE_MULTINET
|
||||
#if defined CONFIG_SR_MN_CN_MULTINET2_SINGLE_RECOGNITION || defined CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION || defined CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION_QUANT8 || defined CONFIG_SR_MN_CN_MULTINET5_SINGLE_RECOGNITION_QUANT8
|
||||
#if defined CONFIG_SR_MN_CN_MULTINET2_SINGLE_RECOGNITION || defined CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION || defined CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION_QUANT8 || defined CONFIG_SR_MN_CN_MULTINET5_RECOGNITION_QUANT8
|
||||
if (i == 0)
|
||||
return CONFIG_CN_SPEECH_COMMAND_ID0;
|
||||
else if (i == 1)
|
||||
@ -461,9 +460,6 @@ char *get_id_name_cn(int i)
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *get_id_name_en(int i)
|
||||
@ -879,20 +875,34 @@ char *get_id_name_en(int i)
|
||||
esp_mn_error_t* esp_mn_commands_update_from_sdkconfig(const esp_mn_iface_t *multinet, model_iface_data_t *model_data)
|
||||
{
|
||||
esp_mn_commands_alloc();
|
||||
printf("esp_mn_commands_update_from_sdkconfig\n");
|
||||
int total_phrase_num = 0;
|
||||
int language_id = 1; // 0: Chinese, 1:English
|
||||
#ifdef CONFIG_SR_MN_CN_MULTINET2_SINGLE_RECOGNITION
|
||||
language_id = 1;
|
||||
#else
|
||||
if (strcmp(ESP_MN_CHINESE, multinet->get_language(model_data)) == 0) {
|
||||
language_id = 1;
|
||||
} else if (strcmp(ESP_MN_ENGLISH, multinet->get_language(model_data)) == 0) {
|
||||
language_id = 2;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Invalid language");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < ESP_MN_MAX_PHRASE_NUM; i++) {
|
||||
char *command_str = NULL;
|
||||
int command_str_len = 0;
|
||||
|
||||
#if defined CONFIG_SR_MN_CN_MULTINET2_SINGLE_RECOGNITION || defined CONFIG_SR_MN_CN_MULTINET4_SINGLE_RECOGNITION || defined CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION || defined CONFIG_SR_MN_CN_MULTINET4_5_SINGLE_RECOGNITION_QUANT8 || defined CONFIG_SR_MN_CN_MULTINET5_SINGLE_RECOGNITION_QUANT8
|
||||
command_str = get_id_name_cn(i);
|
||||
#elif defined CONFIG_SR_MN_EN_MULTINET5_SINGLE_RECOGNITION || defined CONFIG_SR_MN_EN_MULTINET5_SINGLE_RECOGNITION_QUANT8
|
||||
command_str = get_id_name_en(i);
|
||||
#else
|
||||
ESP_LOGE(TAG, "Incorrect language");
|
||||
#endif
|
||||
|
||||
if (language_id == 1) {
|
||||
command_str = get_id_name_cn(i);
|
||||
} else if (language_id == 2) {
|
||||
command_str = get_id_name_en(i);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Invalid language");
|
||||
}
|
||||
|
||||
if (command_str == NULL) continue;
|
||||
command_str_len = strlen(command_str);
|
||||
if (command_str_len <= 0) continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user