mirror of
https://github.com/espressif/esp-sr.git
synced 2025-05-17 23:27:14 +08:00
Merge branch 'feat/threshold' into 'master'
feat: add more interface for afe to modify threshold of wakenet See merge request speech-recognition-framework/esp-sr!167
This commit is contained in:
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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();
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user