diff --git a/docs/en/speech_command_recognition/README.rst b/docs/en/speech_command_recognition/README.rst index 65e4d1c..f736be4 100644 --- a/docs/en/speech_command_recognition/README.rst +++ b/docs/en/speech_command_recognition/README.rst @@ -103,28 +103,6 @@ Customize Speech Commands Via API calls ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Alternatively, speech commands can be modified via API calls, this method works for both MultiNet5 and MultiNet6. -- Print active speech commands, this function will print out all speech commands that are active. - - :: - - /** - * @brief Update the speech commands of MultiNet - * - * @Warning: Must be used after [add/remove/modify/clear] function, - * otherwise the language model of multinet can not be updated. - * - * @param multinet The multinet handle - * @param model_data The model object to query - * - * @return - * - NULL Success - * - others The list of error phrase which can not be parsed by multinet. - */ - esp_mn_error_t *esp_mn_commands_update(); - - .. note:: - The modifications will not be applied, thus not printed out, until you call ``esp_mn_commands_update()``. - - Apply new changes, the add/remove/modify/clear actions will not take effect util this function is called. :: @@ -141,6 +119,8 @@ Alternatively, speech commands can be modified via API calls, this method works */ esp_mn_error_t *esp_mn_commands_update(); + .. note:: + The modifications will not be applied, thus not printed out, until you call ``esp_mn_commands_update()``. - Add a new speech command, will return ``ESP_ERR_INVALID_STATE`` if the input string is not in the correct format. @@ -202,6 +182,24 @@ Alternatively, speech commands can be modified via API calls, this method works */ esp_err_t esp_mn_commands_clear(void); +- Print cached speech commands, this function will print out all cached speech commands. Cached speech commands will be applied after ``esp_mn_commands_update()`` is called. + + :: + + /** + * @brief Print all commands in linked list. + */ + void esp_mn_commands_print(void); + +- Print active speech commands, this function will print out all active speech commands. + + :: + + /** + * @brief Print all commands in linked list. + */ + void print_active_speech_commands(void); + Use MultiNet ------------ diff --git a/docs/zh_CN/speech_command_recognition/README.rst b/docs/zh_CN/speech_command_recognition/README.rst index df04735..e01395a 100644 --- a/docs/zh_CN/speech_command_recognition/README.rst +++ b/docs/zh_CN/speech_command_recognition/README.rst @@ -114,28 +114,6 @@ MultiNet5 定义方法: ~~~~~~~~~~~~~~~~~ 指令还可以通过调用 API 修改,这种方法对于 MultiNet5 和 MultiNet6 都适用。 -- 打印现有指令。 - - :: - - /** - * @brief Update the speech commands of MultiNet - * - * @Warning: Must be used after [add/remove/modify/clear] function, - * otherwise the language model of multinet can not be updated. - * - * @param multinet The multinet handle - * @param model_data The model object to query - * - * @return - * - NULL Success - * - others The list of error phrase which can not be parsed by multinet. - */ - esp_mn_error_t *esp_mn_commands_update(); - - .. note:: - 所有修改操作在调用 ``esp_mn_commands_update()`` 后才会被打印出来。 - - 应用新的修改操作,所有添加、移除、修改及清空操作在调用后才会被应用。 :: @@ -212,6 +190,25 @@ MultiNet5 定义方法: * - ESP_ERR_INVALID_STATE Fail */ esp_err_t esp_mn_commands_clear(void); + + +- 打印缓存的指令, 只有当调用 ``esp_mn_commands_update()`` 缓存指令才会被应用. + + :: + + /** + * @brief Print all commands in linked list. + */ + void esp_mn_commands_print(void); + +- 打印当前已经被应用的指令. + + :: + + /** + * @brief Print all commands in linked list. + */ + void print_active_speech_commands(void); MultiNet 的使用 ---------------- diff --git a/src/esp_mn_speech_commands.c b/src/esp_mn_speech_commands.c index 602d198..3e5fad6 100644 --- a/src/esp_mn_speech_commands.c +++ b/src/esp_mn_speech_commands.c @@ -267,6 +267,13 @@ void esp_mn_commands_print(void) ESP_LOGI(TAG, "---------------------------------------------------------\n"); } +void print_active_speech_commands(void) +{ + ESP_LOGI(TAG, "---------------------ACTIVE SPEECH COMMANDS---------------------"); + esp_mn_model_handle->print_active_speech_commands(esp_mn_model_data); + ESP_LOGI(TAG, "---------------------------------------------------------\n"); +} + void *_esp_mn_calloc_(int n, int size) { #ifdef ESP_PLATFORM diff --git a/src/include/esp_mn_speech_commands.h b/src/include/esp_mn_speech_commands.h index 54623d8..3473fa4 100644 --- a/src/include/esp_mn_speech_commands.h +++ b/src/include/esp_mn_speech_commands.h @@ -163,6 +163,11 @@ esp_mn_node_t *esp_mn_node_alloc(esp_mn_phrase_t *phrase); void esp_mn_node_free(esp_mn_node_t *node); /** - * @brief Print phrase linked list. + * @brief Print all commands in linked list. */ -void esp_mn_commands_print(void); \ No newline at end of file +void esp_mn_commands_print(void); + +/** + * @brief Print all active commands. + */ +void print_active_speech_commands(void); \ No newline at end of file diff --git a/test_apps/esp-sr/main/test_multinet.c b/test_apps/esp-sr/main/test_multinet.c index a17be96..79b57e3 100644 --- a/test_apps/esp-sr/main/test_multinet.c +++ b/test_apps/esp-sr/main/test_multinet.c @@ -173,6 +173,7 @@ TEST_CASE("multinet set commands", "[mn]") } else { printf("Invalid language\n"); } + print_active_speech_commands(); multinet->destroy(model_data); esp_srmodel_deinit(models);