diff --git a/CHANGELOG.md b/CHANGELOG.md index 56896cc..b34dac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Available storage is less than the remaining flash space on IDF v5.0. If you can not map model partition successfully, please check the left free storage by `spi_flash_mmap_get_free_pages(ESP_PARTITION_MMAP_DATA)` or update IDF to v5.1 or later. +# unreleased +- Reduce Internal RAM of multinet7 +- Update benchmark + ## 1.5.0 - Add esp32c6 tts lib - Return the volume of wake word audio when one wake word is detected diff --git a/docs/en/benchmark/README.rst b/docs/en/benchmark/README.rst index 40207a7..c34df15 100644 --- a/docs/en/benchmark/README.rst +++ b/docs/en/benchmark/README.rst @@ -153,6 +153,8 @@ Resource Consumption +-------------+-------------+-------------+-------------+-------------+ | MultiNet 6 | 32 KB | 4100 KB | 12 ms | 32 ms | +-------------+-------------+-------------+-------------+-------------+ + | MultiNet 7 | 20 KB | 3000 KB | 11 ms | 32 ms | + +-------------+-------------+-------------+-------------+-------------+ Word Error Rate Performance Test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/esp32s3/libesp_audio_front_end.a b/lib/esp32s3/libesp_audio_front_end.a index f3aacc5..d02980d 100644 Binary files a/lib/esp32s3/libesp_audio_front_end.a and b/lib/esp32s3/libesp_audio_front_end.a differ diff --git a/lib/esp32s3/libmultinet.a b/lib/esp32s3/libmultinet.a index f18da2b..8e5886e 100644 Binary files a/lib/esp32s3/libmultinet.a and b/lib/esp32s3/libmultinet.a differ diff --git a/lib/esp32s3/libwakenet.a b/lib/esp32s3/libwakenet.a index 2204a1e..6227a7c 100644 Binary files a/lib/esp32s3/libwakenet.a and b/lib/esp32s3/libwakenet.a differ diff --git a/src/esp_mn_speech_commands.c b/src/esp_mn_speech_commands.c index 04d6ac7..2ac2a3e 100644 --- a/src/esp_mn_speech_commands.c +++ b/src/esp_mn_speech_commands.c @@ -12,6 +12,14 @@ static esp_mn_node_t *esp_mn_root = NULL; const static esp_mn_iface_t *esp_mn_model_handle = NULL; static model_iface_data_t *esp_mn_model_data = NULL; +void *_esp_mn_calloc_(int n, int size) +{ +#ifdef ESP_PLATFORM + return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM); +#else + return calloc(n, size); +#endif +} #define ESP_RETURN_ON_FALSE(a, err_code, log_tag, format, ...) do { \ if (!(a)) { \ @@ -130,7 +138,11 @@ esp_err_t esp_mn_commands_add(int command_id, char *string) return ESP_ERR_INVALID_STATE; } #ifdef CONFIG_SR_MN_EN_MULTINET7_QUANT - phrase->phonemes = phonemes; + int phoneme_len = strlen(phonemes); + phrase->phonemes = _esp_mn_calloc_(phoneme_len+1, sizeof(char)); + memcpy(phrase->phonemes, phonemes, phoneme_len); + phrase->phonemes[phoneme_len] = '\0'; + free(phonemes); #endif esp_mn_node_t *new_node = esp_mn_node_alloc(phrase); while (temp->next != NULL) { @@ -168,7 +180,11 @@ esp_err_t esp_mn_commands_modify(char *old_string, char *new_string) return ESP_ERR_INVALID_STATE; } #ifdef CONFIG_SR_MN_EN_MULTINET7_QUANT - phrase->phonemes = phonemes; + int phoneme_len = strlen(phonemes); + phrase->phonemes = _esp_mn_calloc_(phoneme_len+1, sizeof(char)); + memcpy(phrase->phonemes, phonemes, phoneme_len); + phrase->phonemes[phoneme_len] = '\0'; + free(phonemes); #endif esp_mn_phrase_free(temp->phrase); temp->phrase = phrase; @@ -297,15 +313,6 @@ void esp_mn_active_commands_print(void) ESP_LOGI(TAG, "---------------------------------------------------------\n"); } -void *_esp_mn_calloc_(int n, int size) -{ -#ifdef ESP_PLATFORM - return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM); -#else - return calloc(n, size); -#endif -} - esp_mn_phrase_t *esp_mn_phrase_alloc(int command_id, char *string) {