1
+ #pragma once
2
+ #include "stdint.h"
3
+ #include "esp_wn_iface.h"
4
+ #include "esp_wn_models.h"
5
+ #include "esp_vad.h"
6
+
7
+ //AFE: Audio Front-End
8
+ //SR: Speech Recognition
9
+ //afe_sr/AFE_SR: the audio front-end for speech recognition
10
+
11
+ //Set AFE_SR mode
12
+ typedef enum {
13
+ SR_MODE_LOW_COST = 0 ,
14
+ SR_MODE_HIGH_PERF = 1
15
+ } afe_sr_mode_t ;
16
+
17
+ typedef enum {
18
+ AFE_MEMORY_ALLOC_MORE_INTERNAL = 1 , // malloc with more internal ram
19
+ AFE_MEMORY_ALLOC_INTERNAL_PSRAM_BALANCE = 2 , // malloc with internal ram and psram in balance
20
+ AFE_MEMORY_ALLOC_MORE_PSRAM = 3 // malloc with more psram
21
+ } afe_memory_alloc_mode_t ;
22
+
23
+ typedef enum {
24
+ AFE_MN_PEAK_AGC_MODE_1 = -5 , // The peak amplitude of audio fed to multinet is -5dB
25
+ AFE_MN_PEAK_AGC_MODE_2 = -4 , // The peak amplitude of audio fed to multinet is -4dB
26
+ AFE_MN_PEAK_AGC_MODE_3 = -3 , // The peak amplitude of audio fed to multinet is -3dB
27
+ AFE_MN_PEAK_NO_AGC = 0 , // There is no agc gain
28
+ } afe_mn_peak_agc_mode_t ;
29
+
30
+ typedef struct {
31
+ int total_ch_num ; // total channel num. It must be: total_ch_num = mic_num + ref_num
32
+ int mic_num ; // mic channel num
33
+ int ref_num ; // reference channel num
34
+ } afe_pcm_config_t ;
35
+
36
+ typedef struct {
37
+ bool aec_init ;
38
+ bool se_init ;
39
+ bool vad_init ;
40
+ bool wakenet_init ;
41
+ bool voice_communication_init ;
42
+ bool voice_communication_agc_init ; // AGC swich for voice communication
43
+ int voice_communication_agc_gain ; // AGC gain(dB) for voice communication
44
+ vad_mode_t vad_mode ; // The value can be: VAD_MODE_0, VAD_MODE_1, VAD_MODE_2, VAD_MODE_3, VAD_MODE_4
45
+ char * wakenet_model_name ; // The model name of wakenet
46
+ det_mode_t wakenet_mode ;
47
+ afe_sr_mode_t afe_mode ;
48
+ int afe_perferred_core ;
49
+ int afe_perferred_priority ;
50
+ int afe_ringbuf_size ;
51
+ afe_memory_alloc_mode_t memory_alloc_mode ;
52
+ afe_mn_peak_agc_mode_t agc_mode ; // The agc mode for ASR
53
+ afe_pcm_config_t pcm_config ; // Config the channel num of original data which is fed to the afe feed function.
54
+ } afe_config_t ;
55
+
56
+
57
+ #if CONFIG_IDF_TARGET_ESP32
58
+ #define AFE_CONFIG_DEFAULT () { \
59
+ .aec_init = true, \
60
+ .se_init = true, \
61
+ .vad_init = true, \
62
+ .wakenet_init = true, \
63
+ .voice_communication_init = false, \
64
+ .voice_communication_agc_init = false, \
65
+ .voice_communication_agc_gain = 15, \
66
+ .vad_mode = VAD_MODE_3, \
67
+ .wakenet_model_name = NULL, \
68
+ .wakenet_mode = DET_MODE_90, \
69
+ .afe_mode = SR_MODE_HIGH_PERF, \
70
+ .afe_perferred_core = 0, \
71
+ .afe_perferred_priority = 5, \
72
+ .afe_ringbuf_size = 50, \
73
+ .memory_alloc_mode = AFE_MEMORY_ALLOC_INTERNAL_PSRAM_BALANCE, \
74
+ .agc_mode = AFE_MN_PEAK_AGC_MODE_2, \
75
+ .pcm_config.total_ch_num = 2, \
76
+ .pcm_config.mic_num = 1, \
77
+ .pcm_config.ref_num = 1, \
78
+ }
79
+ #elif CONFIG_IDF_TARGET_ESP32S3
80
+ #define AFE_CONFIG_DEFAULT () { \
81
+ .aec_init = true, \
82
+ .se_init = true, \
83
+ .vad_init = true, \
84
+ .wakenet_init = true, \
85
+ .voice_communication_init = false, \
86
+ .voice_communication_agc_init = false, \
87
+ .voice_communication_agc_gain = 15, \
88
+ .vad_mode = VAD_MODE_3, \
89
+ .wakenet_model_name = NULL, \
90
+ .wakenet_mode = DET_MODE_2CH_90, \
91
+ .afe_mode = SR_MODE_LOW_COST, \
92
+ .afe_perferred_core = 0, \
93
+ .afe_perferred_priority = 5, \
94
+ .afe_ringbuf_size = 50, \
95
+ .memory_alloc_mode = AFE_MEMORY_ALLOC_MORE_PSRAM, \
96
+ .agc_mode = AFE_MN_PEAK_AGC_MODE_2, \
97
+ .pcm_config.total_ch_num = 3, \
98
+ .pcm_config.mic_num = 2, \
99
+ .pcm_config.ref_num = 1, \
100
+ }
101
+ #endif
0 commit comments