diff --git a/include/esp32/esp_afe_sr_iface.h b/include/esp32/esp_afe_sr_iface.h index ffc6ce2..b146a54 100644 --- a/include/esp32/esp_afe_sr_iface.h +++ b/include/esp32/esp_afe_sr_iface.h @@ -131,14 +131,23 @@ typedef afe_fetch_result_t *(*esp_afe_sr_iface_op_fetch_with_delay_t)(esp_afe_sr typedef int (*esp_afe_sr_iface_op_reset_buffer_t)(esp_afe_sr_data_t *afe); /** - * @brief Initial wakenet and wake words coefficient, or reset wakenet and wake words coefficient - * when wakenet has been initialized. It's only support wakenet 1 now. - * - * @param afe The AFE_SR object to query - * @param wakenet_word The wakenet word, should be DEFAULT_WAKE_WORD or EXTRA_WAKE_WORD + * @brief Set wakenet detection threshold + * + * @param afe The AFE_SR object to query + * @param index The wakenet index, just support 1: wakenet1 or 2: wakenet2 + * @param threshold The wakenet detection threshold, the value is between 0.4 and 0.9999. * @return -1: fail, 1: success */ -typedef int (*esp_afe_sr_iface_op_set_wakenet_t)(esp_afe_sr_data_t *afe, char *model_name); +typedef int (*esp_afe_sr_iface_op_set_wakenet_threshold_t)(esp_afe_sr_data_t *afe, int index, float threshold); + +/** + * @brief Reset wakenet detection threshold to inital state + * + * @param afe The AFE_SR object to query + * @param index The wakenet index, just support 1: wakenet1 or 2: wakenet2 + * @return -1: fail, 1: success + */ +typedef int (*esp_afe_sr_iface_op_reset_wakenet_threshold_t)(esp_afe_sr_data_t *afe, int index); /** * @brief Reset one function/module/algorithm. @@ -195,7 +204,8 @@ typedef struct { esp_afe_sr_iface_op_get_channel_num_t get_feed_channel_num; esp_afe_sr_iface_op_get_channel_num_t get_fetch_channel_num; esp_afe_sr_iface_op_get_samp_rate_t get_samp_rate; - esp_afe_sr_iface_op_set_wakenet_t set_wakenet; + esp_afe_sr_iface_op_set_wakenet_threshold_t set_wakenet_threshold; + esp_afe_sr_iface_op_reset_wakenet_threshold_t reset_wakenet_threshold; esp_afe_sr_iface_op_disable_func_t disable_wakenet; esp_afe_sr_iface_op_enable_func_t enable_wakenet; esp_afe_sr_iface_op_disable_func_t disable_aec; diff --git a/include/esp32/esp_wn_iface.h b/include/esp32/esp_wn_iface.h index 44bab8d..7cd9a41 100644 --- a/include/esp32/esp_wn_iface.h +++ b/include/esp32/esp_wn_iface.h @@ -110,12 +110,21 @@ typedef char* (*esp_wn_iface_op_get_word_name_t)(model_iface_data_t *model, int * @brief Set the detection threshold to manually abjust the probability * * @param model The model object to query - * @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.5~0.9999 + * @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.4~0.9999 * @param word_index The index of wake word * @return 0: setting failed, 1: setting success */ typedef int (*esp_wn_iface_op_set_det_threshold_t)(model_iface_data_t *model, float det_threshold, int word_index); +/** + * @brief Reset the threshold to its initial state + * + * @param model The model object to query + * @return 0: setting failed, 1: setting success + */ +typedef int (*esp_wn_iface_op_reset_det_threshold_t)(model_iface_data_t *model); + + /** * @brief Get the wake word detection threshold of different modes * @@ -200,6 +209,7 @@ typedef struct { esp_wn_iface_op_get_word_num_t get_word_num; esp_wn_iface_op_get_word_name_t get_word_name; esp_wn_iface_op_set_det_threshold_t set_det_threshold; + esp_wn_iface_op_reset_det_threshold_t reset_det_threshold; esp_wn_iface_op_get_det_threshold_t get_det_threshold; esp_wn_iface_op_get_triggered_channel_t get_triggered_channel; esp_wn_iface_op_get_vol_gain_t get_vol_gain; diff --git a/include/esp32p4/esp_afe_sr_iface.h b/include/esp32p4/esp_afe_sr_iface.h index ffc6ce2..b146a54 100644 --- a/include/esp32p4/esp_afe_sr_iface.h +++ b/include/esp32p4/esp_afe_sr_iface.h @@ -131,14 +131,23 @@ typedef afe_fetch_result_t *(*esp_afe_sr_iface_op_fetch_with_delay_t)(esp_afe_sr typedef int (*esp_afe_sr_iface_op_reset_buffer_t)(esp_afe_sr_data_t *afe); /** - * @brief Initial wakenet and wake words coefficient, or reset wakenet and wake words coefficient - * when wakenet has been initialized. It's only support wakenet 1 now. - * - * @param afe The AFE_SR object to query - * @param wakenet_word The wakenet word, should be DEFAULT_WAKE_WORD or EXTRA_WAKE_WORD + * @brief Set wakenet detection threshold + * + * @param afe The AFE_SR object to query + * @param index The wakenet index, just support 1: wakenet1 or 2: wakenet2 + * @param threshold The wakenet detection threshold, the value is between 0.4 and 0.9999. * @return -1: fail, 1: success */ -typedef int (*esp_afe_sr_iface_op_set_wakenet_t)(esp_afe_sr_data_t *afe, char *model_name); +typedef int (*esp_afe_sr_iface_op_set_wakenet_threshold_t)(esp_afe_sr_data_t *afe, int index, float threshold); + +/** + * @brief Reset wakenet detection threshold to inital state + * + * @param afe The AFE_SR object to query + * @param index The wakenet index, just support 1: wakenet1 or 2: wakenet2 + * @return -1: fail, 1: success + */ +typedef int (*esp_afe_sr_iface_op_reset_wakenet_threshold_t)(esp_afe_sr_data_t *afe, int index); /** * @brief Reset one function/module/algorithm. @@ -195,7 +204,8 @@ typedef struct { esp_afe_sr_iface_op_get_channel_num_t get_feed_channel_num; esp_afe_sr_iface_op_get_channel_num_t get_fetch_channel_num; esp_afe_sr_iface_op_get_samp_rate_t get_samp_rate; - esp_afe_sr_iface_op_set_wakenet_t set_wakenet; + esp_afe_sr_iface_op_set_wakenet_threshold_t set_wakenet_threshold; + esp_afe_sr_iface_op_reset_wakenet_threshold_t reset_wakenet_threshold; esp_afe_sr_iface_op_disable_func_t disable_wakenet; esp_afe_sr_iface_op_enable_func_t enable_wakenet; esp_afe_sr_iface_op_disable_func_t disable_aec; diff --git a/include/esp32p4/esp_wn_iface.h b/include/esp32p4/esp_wn_iface.h index 44bab8d..7cd9a41 100644 --- a/include/esp32p4/esp_wn_iface.h +++ b/include/esp32p4/esp_wn_iface.h @@ -110,12 +110,21 @@ typedef char* (*esp_wn_iface_op_get_word_name_t)(model_iface_data_t *model, int * @brief Set the detection threshold to manually abjust the probability * * @param model The model object to query - * @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.5~0.9999 + * @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.4~0.9999 * @param word_index The index of wake word * @return 0: setting failed, 1: setting success */ typedef int (*esp_wn_iface_op_set_det_threshold_t)(model_iface_data_t *model, float det_threshold, int word_index); +/** + * @brief Reset the threshold to its initial state + * + * @param model The model object to query + * @return 0: setting failed, 1: setting success + */ +typedef int (*esp_wn_iface_op_reset_det_threshold_t)(model_iface_data_t *model); + + /** * @brief Get the wake word detection threshold of different modes * @@ -200,6 +209,7 @@ typedef struct { esp_wn_iface_op_get_word_num_t get_word_num; esp_wn_iface_op_get_word_name_t get_word_name; esp_wn_iface_op_set_det_threshold_t set_det_threshold; + esp_wn_iface_op_reset_det_threshold_t reset_det_threshold; esp_wn_iface_op_get_det_threshold_t get_det_threshold; esp_wn_iface_op_get_triggered_channel_t get_triggered_channel; esp_wn_iface_op_get_vol_gain_t get_vol_gain; diff --git a/include/esp32s3/esp_afe_sr_iface.h b/include/esp32s3/esp_afe_sr_iface.h index ffc6ce2..b146a54 100644 --- a/include/esp32s3/esp_afe_sr_iface.h +++ b/include/esp32s3/esp_afe_sr_iface.h @@ -131,14 +131,23 @@ typedef afe_fetch_result_t *(*esp_afe_sr_iface_op_fetch_with_delay_t)(esp_afe_sr typedef int (*esp_afe_sr_iface_op_reset_buffer_t)(esp_afe_sr_data_t *afe); /** - * @brief Initial wakenet and wake words coefficient, or reset wakenet and wake words coefficient - * when wakenet has been initialized. It's only support wakenet 1 now. - * - * @param afe The AFE_SR object to query - * @param wakenet_word The wakenet word, should be DEFAULT_WAKE_WORD or EXTRA_WAKE_WORD + * @brief Set wakenet detection threshold + * + * @param afe The AFE_SR object to query + * @param index The wakenet index, just support 1: wakenet1 or 2: wakenet2 + * @param threshold The wakenet detection threshold, the value is between 0.4 and 0.9999. * @return -1: fail, 1: success */ -typedef int (*esp_afe_sr_iface_op_set_wakenet_t)(esp_afe_sr_data_t *afe, char *model_name); +typedef int (*esp_afe_sr_iface_op_set_wakenet_threshold_t)(esp_afe_sr_data_t *afe, int index, float threshold); + +/** + * @brief Reset wakenet detection threshold to inital state + * + * @param afe The AFE_SR object to query + * @param index The wakenet index, just support 1: wakenet1 or 2: wakenet2 + * @return -1: fail, 1: success + */ +typedef int (*esp_afe_sr_iface_op_reset_wakenet_threshold_t)(esp_afe_sr_data_t *afe, int index); /** * @brief Reset one function/module/algorithm. @@ -195,7 +204,8 @@ typedef struct { esp_afe_sr_iface_op_get_channel_num_t get_feed_channel_num; esp_afe_sr_iface_op_get_channel_num_t get_fetch_channel_num; esp_afe_sr_iface_op_get_samp_rate_t get_samp_rate; - esp_afe_sr_iface_op_set_wakenet_t set_wakenet; + esp_afe_sr_iface_op_set_wakenet_threshold_t set_wakenet_threshold; + esp_afe_sr_iface_op_reset_wakenet_threshold_t reset_wakenet_threshold; esp_afe_sr_iface_op_disable_func_t disable_wakenet; esp_afe_sr_iface_op_enable_func_t enable_wakenet; esp_afe_sr_iface_op_disable_func_t disable_aec; diff --git a/include/esp32s3/esp_wn_iface.h b/include/esp32s3/esp_wn_iface.h index 44bab8d..7cd9a41 100644 --- a/include/esp32s3/esp_wn_iface.h +++ b/include/esp32s3/esp_wn_iface.h @@ -110,12 +110,21 @@ typedef char* (*esp_wn_iface_op_get_word_name_t)(model_iface_data_t *model, int * @brief Set the detection threshold to manually abjust the probability * * @param model The model object to query - * @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.5~0.9999 + * @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.4~0.9999 * @param word_index The index of wake word * @return 0: setting failed, 1: setting success */ typedef int (*esp_wn_iface_op_set_det_threshold_t)(model_iface_data_t *model, float det_threshold, int word_index); +/** + * @brief Reset the threshold to its initial state + * + * @param model The model object to query + * @return 0: setting failed, 1: setting success + */ +typedef int (*esp_wn_iface_op_reset_det_threshold_t)(model_iface_data_t *model); + + /** * @brief Get the wake word detection threshold of different modes * @@ -200,6 +209,7 @@ typedef struct { esp_wn_iface_op_get_word_num_t get_word_num; esp_wn_iface_op_get_word_name_t get_word_name; esp_wn_iface_op_set_det_threshold_t set_det_threshold; + esp_wn_iface_op_reset_det_threshold_t reset_det_threshold; esp_wn_iface_op_get_det_threshold_t get_det_threshold; esp_wn_iface_op_get_triggered_channel_t get_triggered_channel; esp_wn_iface_op_get_vol_gain_t get_vol_gain; diff --git a/lib/esp32/libesp_audio_front_end.a b/lib/esp32/libesp_audio_front_end.a index e4d546d..197877e 100644 Binary files a/lib/esp32/libesp_audio_front_end.a and b/lib/esp32/libesp_audio_front_end.a differ diff --git a/lib/esp32/libesp_audio_processor.a b/lib/esp32/libesp_audio_processor.a index 05226dc..ffe4bf7 100644 Binary files a/lib/esp32/libesp_audio_processor.a and b/lib/esp32/libesp_audio_processor.a differ diff --git a/lib/esp32/libmultinet.a b/lib/esp32/libmultinet.a index 44b9133..ed8f174 100644 Binary files a/lib/esp32/libmultinet.a and b/lib/esp32/libmultinet.a differ diff --git a/lib/esp32/libwakenet.a b/lib/esp32/libwakenet.a index cd16bfb..8dda950 100644 Binary files a/lib/esp32/libwakenet.a and b/lib/esp32/libwakenet.a differ diff --git a/lib/esp32p4/libesp_audio_front_end.a b/lib/esp32p4/libesp_audio_front_end.a index dfedc11..c2991b0 100644 Binary files a/lib/esp32p4/libesp_audio_front_end.a and b/lib/esp32p4/libesp_audio_front_end.a differ diff --git a/lib/esp32p4/libesp_audio_processor.a b/lib/esp32p4/libesp_audio_processor.a index e31b0a0..8e9c98f 100644 Binary files a/lib/esp32p4/libesp_audio_processor.a and b/lib/esp32p4/libesp_audio_processor.a differ diff --git a/lib/esp32p4/libmultinet.a b/lib/esp32p4/libmultinet.a index 0cbaf88..249c502 100644 Binary files a/lib/esp32p4/libmultinet.a and b/lib/esp32p4/libmultinet.a differ diff --git a/lib/esp32p4/libvadnet.a b/lib/esp32p4/libvadnet.a index aa90d93..969867f 100644 Binary files a/lib/esp32p4/libvadnet.a and b/lib/esp32p4/libvadnet.a differ diff --git a/lib/esp32p4/libwakenet.a b/lib/esp32p4/libwakenet.a index 41573aa..4a74fd8 100644 Binary files a/lib/esp32p4/libwakenet.a and b/lib/esp32p4/libwakenet.a differ diff --git a/lib/esp32s3/libesp_audio_front_end.a b/lib/esp32s3/libesp_audio_front_end.a index 84f6f0c..79d2523 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 39fbd2b..a0f73ea 100644 Binary files a/lib/esp32s3/libmultinet.a and b/lib/esp32s3/libmultinet.a differ diff --git a/lib/esp32s3/libnsnet.a b/lib/esp32s3/libnsnet.a index 75e6edc..713d6ac 100644 Binary files a/lib/esp32s3/libnsnet.a and b/lib/esp32s3/libnsnet.a differ diff --git a/lib/esp32s3/libvadnet.a b/lib/esp32s3/libvadnet.a index 547feaa..da31504 100644 Binary files a/lib/esp32s3/libvadnet.a and b/lib/esp32s3/libvadnet.a differ diff --git a/lib/esp32s3/libwakenet.a b/lib/esp32s3/libwakenet.a index 8ee93d5..a06b735 100644 Binary files a/lib/esp32s3/libwakenet.a and b/lib/esp32s3/libwakenet.a differ diff --git a/test_apps/esp-sr/main/test_afe.cpp b/test_apps/esp-sr/main/test_afe.cpp index 9a52a87..3492011 100644 --- a/test_apps/esp-sr/main/test_afe.cpp +++ b/test_apps/esp-sr/main/test_afe.cpp @@ -60,6 +60,8 @@ void test_afe_by_config(afe_config_t *afe_config, int frame_num, int *memory, fl // run afe feed feed_chunksize = afe_handle->get_feed_chunksize(afe_data); int feed_nch = afe_handle->get_feed_channel_num(afe_data); + afe_handle->set_wakenet_threshold(afe_data, 1, 0.8); + afe_handle->reset_wakenet_threshold(afe_data, 1); int16_t *feed_buff = (int16_t *)malloc(feed_chunksize * sizeof(int16_t) * feed_nch); start = esp_timer_get_time(); diff --git a/test_apps/esp-sr/main/test_wakenet.cpp b/test_apps/esp-sr/main/test_wakenet.cpp index 25fc537..a6a7230 100644 --- a/test_apps/esp-sr/main/test_wakenet.cpp +++ b/test_apps/esp-sr/main/test_wakenet.cpp @@ -92,6 +92,8 @@ TEST_CASE("wakenet detect API & cpu loading", "[wn]") int16_t *buffer = (int16_t *) malloc(audio_chunksize); int chunks = 0; int detected = 0; + wakenet->set_det_threshold(model_data, 0.8, 1); + wakenet->reset_det_threshold(model_data); struct timeval tv_start, tv_end; gettimeofday(&tv_start, NULL); unsigned char* data = NULL;