3636#else
3737#define VCMD_ENABLE (false)
3838#endif /* CONFIG_GMF_AI_AUDIO_VOICE_COMMAND_ENABLE */
39- #define VAD_ENABLE (true)
4039#define QUIT_CMD_FOUND (BIT0)
4140
4241#define BOARD_LYRAT_MINI (0)
6463#define INPUT_CH_NUM (4)
6564#define INPUT_CH_BITS (16) /* For board `ESP32-S3-Korvo-2`, the es7210 is configured as 32-bit,
6665 2-channel mode to accommodate 16-bit, 4-channel data */
67- #define INPUT_CH_ALLOCATION ("RMNM")
6866#elif AUDIO_BOARD == BOARD_LYRAT_MINI
6967#define ADC_I2S_CH (2)
7068#define ADC_I2S_BITS (16)
7169#define INPUT_CH_NUM (ADC_I2S_CH)
7270#define INPUT_CH_BITS (ADC_I2S_BITS)
73- #define INPUT_CH_ALLOCATION ("RM")
7471#elif AUDIO_BOARD == BOARD_XD_AIOT_C3
7572#define ADC_I2S_CH (2)
7673#define ADC_I2S_BITS (16)
7774#define INPUT_CH_NUM (ADC_I2S_CH)
7875#define INPUT_CH_BITS (ADC_I2S_BITS)
79- #define INPUT_CH_ALLOCATION ("MR")
8076#elif AUDIO_BOARD == BOARD_ESP_SPOT
8177#define ADC_I2S_CH (2)
8278#define ADC_I2S_BITS (16)
8379#define INPUT_CH_NUM (ADC_I2S_CH)
8480#define INPUT_CH_BITS (ADC_I2S_BITS)
85- #define INPUT_CH_ALLOCATION ("MR")
8681#endif /* AUDIO_BOARD == BOARD_KORVO_2 */
8782
8883#if WITH_AFE == true
@@ -98,7 +93,9 @@ static bool speeching = false;
9893static bool wakeup = false;
9994#endif /* WITH_AFE == true */
10095static EventGroupHandle_t g_event_group = NULL ;
96+ #if WITH_AFE == true
10197static esp_gmf_element_handle_t g_afe = NULL ;
98+ #endif /* WITH_AFE == true */
10299
103100static esp_err_t _pipeline_event (esp_gmf_event_pkt_t * event , void * ctx )
104101{
@@ -118,8 +115,12 @@ void esp_gmf_afe_event_cb(esp_gmf_obj_handle_t obj, esp_gmf_afe_evt_t *event, vo
118115 esp_gmf_afe_vcmd_detection_cancel (obj );
119116 esp_gmf_afe_vcmd_detection_begin (obj );
120117#endif /* WAKENET_ENABLE == true && VCMD_ENABLE == true */
121- esp_gmf_afe_wakeup_info_t * info = event -> event_data ;
122- ESP_LOGI (TAG , "WAKEUP_START [%d : %d]" , info -> wake_word_index , info -> wakenet_model_index );
118+ if (event -> event_data ) {
119+ esp_gmf_afe_wakeup_info_t * info = event -> event_data ;
120+ ESP_LOGI (TAG , "WAKEUP_START [%d : %d]" , info -> wake_word_index , info -> wakenet_model_index );
121+ } else {
122+ ESP_LOGI (TAG , "WAKEUP_START" );
123+ }
123124 break ;
124125 }
125126 case ESP_GMF_AFE_EVT_WAKEUP_END : {
@@ -172,7 +173,7 @@ static void esp_gmf_wn_event_cb(esp_gmf_obj_handle_t obj, int32_t trigger_ch, vo
172173
173174static void voice_2_file (uint8_t * buffer , int len )
174175{
175- #if VOICE2FILE == true
176+ #if VOICE2FILE == true && WITH_AFE == true
176177#define MAX_FNAME_LEN (50)
177178
178179 static FILE * fp = NULL ;
@@ -198,7 +199,7 @@ static void voice_2_file(uint8_t *buffer, int len)
198199 fp = NULL ;
199200 }
200201 }
201- #endif /* VOICE2FILE == true */
202+ #endif /* VOICE2FILE == true && WITH_AFE == true */
202203}
203204
204205static esp_gmf_err_io_t outport_acquire_write (void * handle , esp_gmf_payload_t * load , int wanted_size , int block_ticks )
@@ -214,6 +215,7 @@ static esp_gmf_err_io_t outport_release_write(void *handle, esp_gmf_payload_t *l
214215 return ESP_GMF_IO_OK ;
215216}
216217
218+ #if WITH_AFE == true
217219static struct {
218220 struct arg_int * keep ;
219221 struct arg_end * end ;
@@ -235,6 +237,29 @@ static int keep_awake(int argc, char **argv)
235237 return ESP_OK ;
236238}
237239
240+ static struct {
241+ struct arg_str * cmd ;
242+ struct arg_end * end ;
243+ } trigger_args ;
244+
245+ static int trigger (int argc , char * * argv )
246+ {
247+ int nerrors = arg_parse (argc , argv , (void * * )& trigger_args );
248+ if (nerrors != 0 ) {
249+ arg_print_errors (stderr , trigger_args .end , argv [0 ]);
250+ return ESP_FAIL ;
251+ }
252+ if (g_afe ) {
253+ if (strcmp (trigger_args .cmd -> sval [0 ], "wakeup" ) == 0 ) {
254+ esp_gmf_afe_trigger_wakeup (g_afe );
255+ } else if (strcmp (trigger_args .cmd -> sval [0 ], "sleep" ) == 0 ) {
256+ esp_gmf_afe_trigger_sleep (g_afe );
257+ }
258+ }
259+ return 0 ;
260+ }
261+ #endif /* WITH_AFE == true */
262+
238263static int quit (int argc , char * * argv )
239264{
240265 xEventGroupSetBits (g_event_group , QUIT_CMD_FOUND );
@@ -243,6 +268,7 @@ static int quit(int argc, char **argv)
243268
244269static void wwe_cmds_register (void )
245270{
271+ #if WITH_AFE == true
246272 esp_console_cmd_t cmd_keep = {
247273 .command = "keep" ,
248274 .help = "keep awake" ,
@@ -254,6 +280,18 @@ static void wwe_cmds_register(void)
254280 keep_args .end = arg_end (1 );
255281 esp_console_cmd_register (& cmd_keep );
256282
283+ esp_console_cmd_t cmd_trigger_wakeup = {
284+ .command = "trigger" ,
285+ .help = "trigger wakeup or sleep" ,
286+ .hint = NULL ,
287+ .func = & trigger ,
288+ .argtable = & trigger_args ,
289+ };
290+ trigger_args .cmd = arg_str0 (NULL , NULL , "<wakeup|sleep>" , "Trigger wakeup or sleep" );
291+ trigger_args .end = arg_end (1 );
292+ esp_console_cmd_register (& cmd_trigger_wakeup );
293+ #endif /* WITH_AFE == true */
294+
257295 esp_console_cmd_t cmd_quit = {
258296 .command = "quit" ,
259297 .help = "quit" ,
0 commit comments