feature/Support continuous wakeup mode

This commit is contained in:
Wang Wang Wang 2020-04-26 17:15:46 +08:00
parent 221c741676
commit 87bb8b5cf3
3 changed files with 9 additions and 35 deletions

Binary file not shown.

View File

@ -9,7 +9,6 @@
#include "esp_aec.h"
#include "esp_agc.h"
#include "esp_vad.h"
#include "esp_map.h"
#include "audio_test_file.h"
void NSTask(void *arg)
@ -106,36 +105,6 @@ void VADTask(void *arg)
vTaskDelete(NULL);
}
void MAPTask(void *arg)
{
mic_array_processor_t map_st = map_create(MAP_SAMPLE_RATE, MAP_FRAME_SIZE, THREE_MIC_CIRCLE, MAP_MIC_DISTANCE, MAP_AEC_ON, MAP_AEC_FILTER_LENGTH);
int chunks = 0;
int nch = 3;
int audio_chunksize = MAP_FRAME_SIZE * MAP_SAMPLE_RATE * 3 / 1000;
int16_t *map_in = malloc(audio_chunksize * sizeof(int16_t));
int16_t *map_ref = malloc(audio_chunksize / 3 * sizeof(int16_t));
int16_t *map_out = malloc(audio_chunksize / 3 * sizeof(int16_t));
while (1) {
if ((chunks + 1) * audio_chunksize * sizeof(int16_t) <= sizeof(audio_test_file)) {
memcpy(map_in, audio_test_file + chunks * audio_chunksize * sizeof(int16_t), audio_chunksize * sizeof(int16_t));
memset(map_ref, 0, audio_chunksize / 3 * sizeof(int16_t));
memset(map_out, 0, audio_chunksize / 3 * sizeof(int16_t));
} else {
break;
}
map_process(map_st, map_in, map_ref, map_out);
chunks++;
}
map_destory(map_st);
free(map_in);
free(map_ref);
free(map_out);
printf("MAP test successfully\n\n");
printf("TEST3 FINISHED\n\n");
vTaskDelete(NULL);
}
void audio_process_test()
{
@ -146,6 +115,4 @@ void audio_process_test()
xTaskCreatePinnedToCore(&AECTask, "acoustic_echo_cancellation", 3 * 1024, NULL, 5, NULL, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS);
xTaskCreatePinnedToCore(&VADTask, "voice_activity_detection", 3 * 1024, NULL, 5, NULL, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS);
xTaskCreatePinnedToCore(&MAPTask, "mic_array_processing", 3 * 1024, NULL, 5, NULL, 0);
}

View File

@ -11,7 +11,7 @@
*
* @param coeff The wakenet model coefficient.
* @param coeff The wakenet model coefficient.
* @parm sample_length Audio length for speech recognition, in ms. The range of sample_length is 0~6000.
* @parm sample_length Audio length for speech recognition, in ms.
* @returns Handle to the model data.
*/
typedef model_iface_data_t* (*esp_mn_iface_op_create_t)(const model_coeff_getter_t *coeff, int sample_length);
@ -64,12 +64,18 @@ typedef int (*esp_mn_iface_op_detect_t)(model_iface_data_t *model, int16_t *samp
/**
* @brief Destroy a voiceprint recognition model
* @brief Destroy a speech commands recognition model
*
* @param model The Model object to destroy
*/
typedef void (*esp_mn_iface_op_destroy_t)(model_iface_data_t *model);
/**
* @brief Reset the speech commands recognition model
*
*/
typedef void (*esp_mn_iface_op_reset_t)(void);
typedef struct {
esp_mn_iface_op_create_t create;
esp_mn_iface_op_get_samp_rate_t get_samp_rate;
@ -78,4 +84,5 @@ typedef struct {
esp_mn_iface_op_set_det_threshold_t set_det_threshold;
esp_mn_iface_op_detect_t detect;
esp_mn_iface_op_destroy_t destroy;
esp_mn_iface_op_reset_t reset;
} esp_mn_iface_t;