esp-adf icon indicating copy to clipboard operation
esp-adf copied to clipboard

Adding gesture to wake word detection - is there a better way? (AUD-4838)

Open mjhewitt1 opened this issue 2 years ago • 1 comments

I am looking to add a gesture to the wake word detection process. The gesture recognition happens on a watch device and when a gesture is recognised, a 1 is sent over esp now to the ESP-BOX.

To make it so that the ESP-BOX only wakes up if the wake word is detected AND a gesture is recognised, I have edited the audio_recorder_update_state() function in esp-adf/components/audio_recorder/audio_recorder.c so that the state only changes from IDLE if the wakeword is detected && gest_now == 1. I have added another function to audio_recorder.c so that the value of gest_now is updated when data is received from the watch device. The changes are outlined below.

It currently works, however I am wondering if there is a better way to do this whereby I do not need to alter the esp-adf library and can achieve this same functionality from outside the audio_recorder.c file? Thanks :)


esp-adf/components/audio_recorder/audio_recorder.c - additions:

typedef struct struct_message { uint8_t wake; } struct_message; struct_message gesture;

uint8_t gest_now;

void onDataReceived(const uint8_t *macaddr, const uint8_t *data, int dataLen) { memcpy(&gesture, data, sizeof(gesture)); gest_now = gesture.wake; ESP_LOGE(TAG, "GEST NOW %d", gest_now); }

static void audio_recorder_update_state(audio_recorder_t *recorder, int event) { switch (recorder->state) { case RECORDER_ST_IDLE: { if (event == RECORDER_EVENT_WWE_DECT && gest_now == 1) { ……. } break; } ………….. }

mjhewitt1 avatar Aug 23 '23 11:08 mjhewitt1

Hi @mjhewitt1 , if you don't want to make any change of the esp-adf library, you can check the gest_now flag when AUDIO_REC_WAKEUP_START triggered in rec_engine_cb, then invoke audio_recorder_trigger_stop to stop the wake up process if the flag is not set.

JosephTang avatar Sep 14 '23 11:09 JosephTang