mirror of
https://github.com/espressif/esp-sr.git
synced 2025-09-15 15:28:44 +08:00
feat(mn): Output text of ctc greedy search result when no command can be detected
This commit is contained in:
parent
7ba6ef3b20
commit
01ddb1bf84
@ -4,6 +4,9 @@
|
||||
- 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
|
||||
- Output text of ctc greedy search result when no command can be detected.
|
||||
|
||||
## 1.3.1
|
||||
- Bugfix: remove all cxx11:string
|
||||
- Bugfix: remove esp-partition for esp32s2 & esp32c3 on idf v4.4
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -187,7 +187,10 @@ esp_err_t esp_mn_commands_remove(char *string)
|
||||
|
||||
esp_mn_phrase_t *esp_mn_commands_get_from_index(int index)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(NULL != esp_mn_root, NULL, TAG, "The mn commands is not initialized");
|
||||
if (NULL == esp_mn_root) {
|
||||
ESP_LOGW(TAG, "%s", "The mn commands is not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// phrase index also is phrase id, which is the depth from this phrase node to root node
|
||||
esp_mn_node_t *temp = esp_mn_root;
|
||||
@ -203,7 +206,10 @@ esp_mn_phrase_t *esp_mn_commands_get_from_index(int index)
|
||||
|
||||
esp_mn_phrase_t *esp_mn_commands_get_from_string(const char *string)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(NULL != esp_mn_root, NULL, TAG, "The mn commands is not initialized");
|
||||
if (NULL == esp_mn_root) {
|
||||
ESP_LOGW(TAG, "%s", "The mn commands is not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// phrase index also is phrase id, which is the depth from this phrase node to root node
|
||||
esp_mn_node_t *temp = esp_mn_root;
|
||||
@ -217,6 +223,25 @@ esp_mn_phrase_t *esp_mn_commands_get_from_string(const char *string)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *esp_mn_commands_get_string(int command_id)
|
||||
{
|
||||
if (NULL == esp_mn_root) {
|
||||
ESP_LOGW(TAG, "%s", "The mn commands is not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// phrase index also is phrase id, which is the depth from this phrase node to root node
|
||||
esp_mn_node_t *temp = esp_mn_root;
|
||||
while (temp->next) {
|
||||
if (temp->next->phrase->command_id == command_id) {
|
||||
return temp->next->phrase->string;
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
esp_mn_error_t *esp_mn_commands_update()
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(NULL != esp_mn_root, NULL, TAG, "The mn commands is not initialize");
|
||||
@ -260,7 +285,7 @@ esp_mn_phrase_t *esp_mn_phrase_alloc(int command_id, char *string)
|
||||
esp_mn_phrase_t *phrase = _esp_mn_calloc_(1, sizeof(esp_mn_phrase_t));
|
||||
ESP_RETURN_ON_FALSE(NULL != phrase, NULL, TAG, "Fail to alloc mn phrase");
|
||||
|
||||
phrase->string = malloc((string_len+1) * sizeof(char));
|
||||
phrase->string = _esp_mn_calloc_(string_len+1, sizeof(char));
|
||||
memcpy(phrase->string, string, string_len);
|
||||
phrase->string[string_len] = '\0';
|
||||
phrase->command_id = command_id;
|
||||
|
||||
@ -23,7 +23,10 @@ It is easy to add one speech command into linked list and remove one speech comm
|
||||
|
||||
/**
|
||||
* @brief Initialze the speech commands singly linked list.
|
||||
*
|
||||
*
|
||||
* @param multinet The handle of multinet
|
||||
* @param model_data The model data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NO_MEM No memory
|
||||
@ -43,8 +46,8 @@ esp_err_t esp_mn_commands_free(void);
|
||||
/**
|
||||
* @brief Add one speech commands with command string and command ID
|
||||
*
|
||||
* @param command_id The command ID
|
||||
* @param string The command string of the speech commands
|
||||
* @param command_id The command ID
|
||||
* @param string The command string of the speech commands
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -55,8 +58,8 @@ esp_err_t esp_mn_commands_add(int command_id, char *string);
|
||||
/**
|
||||
* @brief Modify one speech commands with new command string
|
||||
*
|
||||
* @param old_string The old command string of the speech commands
|
||||
* @param new_string The new command string of the speech commands
|
||||
* @param old_string The old command string of the speech commands
|
||||
* @param new_string The new command string of the speech commands
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -67,7 +70,7 @@ esp_err_t esp_mn_commands_modify(char *old_string, char *new_string);
|
||||
/**
|
||||
* @brief Remove one speech commands by command string
|
||||
*
|
||||
* @param string The command string of the speech commands
|
||||
* @param string The command string of the speech commands
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -84,10 +87,23 @@ esp_err_t esp_mn_commands_remove(char *string);
|
||||
*/
|
||||
esp_err_t esp_mn_commands_clear(void);
|
||||
|
||||
/**
|
||||
* @brief Get string of command from command_id
|
||||
*
|
||||
* @param command_id The command ID
|
||||
*
|
||||
* @return
|
||||
* - char* Success
|
||||
* - NULL Fail
|
||||
*/
|
||||
char *esp_mn_commands_get_string(int command_id);
|
||||
|
||||
/**
|
||||
* @brief Get phrase from index, which is the depth from the phrase node to root node
|
||||
*
|
||||
* @Warning: The first phrase index is 0, the second phrase index is 1, and so on.
|
||||
* @warning: The first phrase index is 0, the second phrase index is 1, and so on.
|
||||
*
|
||||
* @param index The phrase index in speech commands list
|
||||
*
|
||||
* @return
|
||||
* - esp_mn_phrase_t* Success
|
||||
@ -98,6 +114,8 @@ esp_mn_phrase_t *esp_mn_commands_get_from_index(int index);
|
||||
/**
|
||||
* @brief Get phrase from command string
|
||||
*
|
||||
* @param string The string of the command
|
||||
*
|
||||
* @return
|
||||
* - esp_mn_phrase_t* Success
|
||||
* - NULL Fail
|
||||
@ -126,7 +144,7 @@ esp_mn_phrase_t *esp_mn_phrase_alloc(int command_id, char *string);
|
||||
/**
|
||||
* @brief Free esp_mn_phrase_t pointer.
|
||||
*
|
||||
* @param phrase The esp_mn_phrase_t pointer
|
||||
* @param phrase The esp_mn_phrase_t pointer
|
||||
*/
|
||||
void esp_mn_phrase_free(esp_mn_phrase_t *phrase);
|
||||
|
||||
@ -140,7 +158,7 @@ esp_mn_node_t *esp_mn_node_alloc(esp_mn_phrase_t *phrase);
|
||||
/**
|
||||
* @brief Free esp_mn_node_t pointer.
|
||||
*
|
||||
* @param node The esp_mn_node_free pointer
|
||||
* @param node The esp_mn_node_free pointer
|
||||
*/
|
||||
void esp_mn_node_free(esp_mn_node_t *node);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user