mirror of
https://github.com/espressif/esp-sr.git
synced 2025-09-15 15:28:44 +08:00
feat(model & AFE): Support model in SDCard; Modify the spiffs base path; Supoort hi,ESP wake word; Merge feed and mase tasks when aec not init
This commit is contained in:
parent
21008cf87c
commit
bccbd966cc
@ -1,5 +1,6 @@
|
||||
set(COMPONENT_SRCS
|
||||
speech_command_recognition/mn_process_commands.c
|
||||
model/model_path.c
|
||||
)
|
||||
|
||||
set(COMPONENT_ADD_INCLUDEDIRS
|
||||
@ -9,26 +10,16 @@ set(COMPONENT_ADD_INCLUDEDIRS
|
||||
acoustic_algorithm/include
|
||||
esp-tts/esp_tts_chinese/include
|
||||
audio_front_end/include
|
||||
model
|
||||
)
|
||||
|
||||
set(COMPONENT_REQUIRES
|
||||
json
|
||||
spiffs
|
||||
)
|
||||
|
||||
register_component()
|
||||
|
||||
set(MVMODEL_EXE ${COMPONENT_PATH}/model/movemodel.py)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${COMPONENT_DIR}/model/target/_MODEL_INFO_
|
||||
COMMENT "Running move model..."
|
||||
COMMAND python ${MVMODEL_EXE} -d1 ${PROJECT_DIR} -d2 ${COMPONENT_PATH}
|
||||
DEPENDS ${COMPONENT_DIR}/model/
|
||||
VERBATIM)
|
||||
|
||||
add_custom_target(model DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_)
|
||||
add_dependencies(${COMPONENT_LIB} model)
|
||||
|
||||
target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||
target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/wake_word_engine")
|
||||
target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/speech_command_recognition")
|
||||
@ -85,4 +76,18 @@ target_link_libraries(${COMPONENT_TARGET} "-Wl,--start-group"
|
||||
"-Wl,--end-group")
|
||||
endif()
|
||||
|
||||
spiffs_create_partition_image(model ${COMPONENT_DIR}/model/target FLASH_IN_PROJECT DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_)
|
||||
set(MVMODEL_EXE ${COMPONENT_PATH}/model/movemodel.py)
|
||||
|
||||
if(CONFIG_MODEL_IN_SPIFFS AND CONFIG_USE_WAKENET)
|
||||
add_custom_command(
|
||||
OUTPUT ${COMPONENT_DIR}/model/target/_MODEL_INFO_
|
||||
COMMENT "Running move model..."
|
||||
COMMAND python ${MVMODEL_EXE} -d1 ${PROJECT_DIR} -d2 ${COMPONENT_PATH}
|
||||
DEPENDS ${COMPONENT_DIR}/model/
|
||||
VERBATIM)
|
||||
|
||||
add_custom_target(model DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_)
|
||||
add_dependencies(${COMPONENT_LIB} model)
|
||||
|
||||
spiffs_create_partition_image(model ${COMPONENT_DIR}/model/target FLASH_IN_PROJECT DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_)
|
||||
endif()
|
||||
@ -24,6 +24,17 @@ choice NET_TO_USE_ACCELERATION
|
||||
|
||||
endchoice
|
||||
|
||||
choice MODEL_DATA_PATH
|
||||
prompt "model data path"
|
||||
default MODEL_IN_SPIFFS
|
||||
|
||||
config MODEL_IN_SPIFFS
|
||||
bool "spiffs partition"
|
||||
|
||||
config MODEL_IN_SDCARD
|
||||
bool "SD Card"
|
||||
endchoice
|
||||
|
||||
config USE_WAKENET
|
||||
bool "use wakenet"
|
||||
default "y"
|
||||
@ -61,23 +72,23 @@ choice SR_WN_WAKE_WORD_SEL
|
||||
Select the wake word to be used.
|
||||
|
||||
config SR_WN_WN3_HILEXIN
|
||||
bool "hilexin (WakeNet3)"
|
||||
bool "Hi,Lexin (WakeNet3)"
|
||||
depends on SR_WN_MODEL_WN3_QUANT
|
||||
|
||||
config SR_WN_WN4_HILEXIN
|
||||
bool "hilexin (WakeNet4)"
|
||||
bool "Hi,Lexin (WakeNet4)"
|
||||
depends on SR_WN_MODEL_WN4_QUANT
|
||||
|
||||
config SR_WN_WN5_HILEXIN
|
||||
bool "hilexin (WakeNet5)"
|
||||
bool "Hi,Lexin (WakeNet5)"
|
||||
depends on SR_WN_MODEL_WN5_QUANT || SR_WN_MODEL_WN5_FLOAT
|
||||
|
||||
config SR_WN_WN5X2_HILEXIN
|
||||
bool "hilexin (WakeNet5X2)"
|
||||
bool "Hi,Lexin (WakeNet5X2)"
|
||||
depends on SR_WN_MODEL_WN5_QUANT || SR_WN_MODEL_WN5_FLOAT
|
||||
|
||||
config SR_WN_WN5X3_HILEXIN
|
||||
bool "hilexin (WakeNet5X3)"
|
||||
bool "Hi,Lexin (WakeNet5X3)"
|
||||
depends on SR_WN_MODEL_WN5_QUANT || SR_WN_MODEL_WN5_FLOAT
|
||||
|
||||
config SR_WN_WN5_NIHAOXIAOZHI
|
||||
@ -117,13 +128,17 @@ choice SR_WN_WAKE_WORD_SEL
|
||||
depends on SR_WN_MODEL_WN7_QUANT || SR_WN_MODEL_WN7_QUANT8
|
||||
|
||||
config SR_WN_WN7_HILEXIN
|
||||
bool "hilexin (WakeNet7)"
|
||||
bool "Hi,Lexin (WakeNet7)"
|
||||
depends on SR_WN_MODEL_WN7_QUANT || SR_WN_MODEL_WN7_QUANT8
|
||||
|
||||
config SR_WN_WN8_ALEXA
|
||||
bool "Alexa (WakeNet8)"
|
||||
depends on SR_WN_MODEL_WN8_QUANT || SR_WN_MODEL_WN8_QUANT8
|
||||
|
||||
config SR_WN_WN8_HIESP
|
||||
bool "Hi,ESP (WakeNet8)"
|
||||
depends on SR_WN_MODEL_WN8_QUANT || SR_WN_MODEL_WN8_QUANT8
|
||||
|
||||
endchoice
|
||||
|
||||
config USE_MULTINET
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
lib/libhufzip.a
BIN
lib/libhufzip.a
Binary file not shown.
Binary file not shown.
BIN
lib/libwakenet.a
BIN
lib/libwakenet.a
Binary file not shown.
@ -1 +1 @@
|
||||
608e25672593e68a3b455d76292abeb23b25ff20
|
||||
cf03dda67d53d5a85d6f8c7ee0dcb05300fe31de
|
||||
11
model/CMakeLists.txt
Normal file
11
model/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
set(COMPONENT_SRCS
|
||||
model_path.c
|
||||
)
|
||||
|
||||
set(COMPONENT_ADD_INCLUDEDIRS .)
|
||||
|
||||
set(COMPONENT_REQUIRES
|
||||
spiffs
|
||||
)
|
||||
|
||||
register_component()
|
||||
49
model/model_path.c
Normal file
49
model/model_path.c
Normal file
@ -0,0 +1,49 @@
|
||||
#include "stdio.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
char *get_model_base_path(void)
|
||||
{
|
||||
#if defined CONFIG_MODEL_IN_SDCARD
|
||||
return "sdcard";
|
||||
#elif defined CONFIG_MODEL_IN_SPIFFS
|
||||
return "srmodel";
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void srmodel_spiffs_init(void)
|
||||
{
|
||||
#include "esp_spiffs.h"
|
||||
printf("Initializing SPIFFS\n");
|
||||
|
||||
esp_vfs_spiffs_conf_t conf = {
|
||||
.base_path = "/srmodel",
|
||||
.partition_label = "model",
|
||||
.max_files = 5,
|
||||
.format_if_mount_failed = true
|
||||
};
|
||||
|
||||
// Use settings defined above to initialize and mount SPIFFS filesystem.
|
||||
// Note: esp_vfs_spiffs_register is an all-in-one convenience function.
|
||||
esp_err_t ret = esp_vfs_spiffs_register(&conf);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
if (ret == ESP_FAIL) {
|
||||
printf("Failed to mount or format filesystem\n");
|
||||
} else if (ret == ESP_ERR_NOT_FOUND) {
|
||||
printf("Failed to find SPIFFS partition\n");
|
||||
} else {
|
||||
printf("Failed to initialize SPIFFS (%s)\n", esp_err_to_name(ret));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
size_t total = 0, used = 0;
|
||||
ret = esp_spiffs_info("model", &total, &used);
|
||||
if (ret != ESP_OK) {
|
||||
printf("Failed to get SPIFFS partition information (%s)\n", esp_err_to_name(ret));
|
||||
} else {
|
||||
printf("Partition size: total: %d, used: %d\n", total, used);
|
||||
}
|
||||
}
|
||||
3
model/model_path.h
Normal file
3
model/model_path.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
char *get_model_base_path(void);
|
||||
void srmodel_spiffs_init(void);
|
||||
@ -2,6 +2,16 @@ import io
|
||||
import os
|
||||
import argparse
|
||||
|
||||
def calculate_total_size(folder_path):
|
||||
total_size = 0
|
||||
for file_name in os.listdir(folder_path):
|
||||
path = os.path.join(folder_path, file_name)
|
||||
if os.path.isdir(path):
|
||||
total_size = total_size + calculate_total_size(path)
|
||||
if os.path.isfile(path):
|
||||
total_size = total_size + os.path.getsize(path)
|
||||
return total_size
|
||||
|
||||
if __name__ == '__main__':
|
||||
# input parameter
|
||||
parser = argparse.ArgumentParser(description='Model generator tool')
|
||||
@ -40,6 +50,8 @@ elif "CONFIG_SR_WN_WN7_ALEXA" in WN_STRING and "CONFIG_SR_WN_MODEL_WN7_QUANT" in
|
||||
wakenet_model = 'alexa7'
|
||||
elif "CONFIG_SR_WN_WN8_ALEXA" in WN_STRING and "CONFIG_SR_WN_MODEL_WN8_QUANT" in WN_STRING:
|
||||
wakenet_model = 'alexa8'
|
||||
elif "CONFIG_SR_WN_WN8_HIESP" in WN_STRING and "CONFIG_SR_WN_MODEL_WN8_QUANT" in WN_STRING:
|
||||
wakenet_model = 'hiesp8'
|
||||
else:
|
||||
print('choose no wakenet mode')
|
||||
|
||||
@ -71,4 +83,7 @@ if wakenet_model != 'null':
|
||||
os.system("cp %s %s -rf" % (wakenet_model, target_model))
|
||||
if multinet_model != 'null':
|
||||
os.system("cp %s %s -rf" % (multinet_model, target_model))
|
||||
os.system("cp %s %s" % (wakenet_model+'/_MODEL_INFO_', target_model))
|
||||
os.system("cp %s %s" % (wakenet_model+'/_MODEL_INFO_', target_model))
|
||||
|
||||
total_size = calculate_total_size(target_model)
|
||||
print("Recommended model partition size: ", str(int((total_size / 1024 + 500) / 4 ) * 4) + 'KB')
|
||||
|
||||
@ -1 +1 @@
|
||||
wakeNet8_v2_alexa_5_0.58_0.55
|
||||
wakeNet8_v5_alexa_5_0.55_0.54
|
||||
Binary file not shown.
Binary file not shown.
1
model/wakenet_model/hiesp8/_MODEL_INFO_
Normal file
1
model/wakenet_model/hiesp8/_MODEL_INFO_
Normal file
@ -0,0 +1 @@
|
||||
WakeNet8_v2_hiesp_5_0.55_0.50
|
||||
BIN
model/wakenet_model/hiesp8/wn8_data
Normal file
BIN
model/wakenet_model/hiesp8/wn8_data
Normal file
Binary file not shown.
BIN
model/wakenet_model/hiesp8/wn8_index
Normal file
BIN
model/wakenet_model/hiesp8/wn8_index
Normal file
Binary file not shown.
@ -88,6 +88,9 @@ extern const esp_wn_iface_t esp_sr_wakenet8_quantized;
|
||||
#elif CONFIG_SR_WN_WN7_ALEXA & CONFIG_SR_WN_MODEL_WN7_QUANT8
|
||||
#define WAKENET_COEFF "alexa7q8"
|
||||
|
||||
#elif CONFIG_SR_WN_WN8_HIESP & CONFIG_SR_WN_MODEL_WN8_QUANT
|
||||
#define WAKENET_COEFF "hiesp8"
|
||||
|
||||
#else
|
||||
#error No valid wake word selected.
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user