Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] I'm trying to use the words multinet to run app_sr_start_once() by disabling wakenet, in the example chatgpt_demo (AEGHB-368) #93

Closed
kostt opened this issue Sep 1, 2023 · 2 comments

Comments

@kostt
Copy link

kostt commented Sep 1, 2023

Having disabled wakenet, I try to catch multinet commands in a loop to run app_sr_start_once(). It works but sometimes it crashes and I get an error. Is it possible to optimize this somehow?

Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x420b6003 PS : 0x00060930 A0 : 0x80387fdd A1 : 0x3fcbf2d0
0x420b6003: ieee80211_crypto_decap at ??:?

A2 : 0x3c4a6754 A3 : 0x3c7e309c A4 : 0x00000018 A5 : 0x00000018
A6 : 0x3c7e312c A7 : 0x3c7e309c A8 : 0x00170032 A9 : 0x3c7e3144
A10 : 0x3c4a6754 A11 : 0x3c7e309c A12 : 0x00000018 A13 : 0x3fcbd40c
A14 : 0x4037dcc8 A15 : 0x00000640 SAR : 0x00000020 EXCCAUSE: 0x0000001c
0x4037dcc8: task_ms_to_tick_wrapper at /Users/Test/esp/esp-idf/components/esp_wifi/esp32s3/esp_adapter.c:307

EXCVADDR: 0x00170046 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff
0x40056f5c: memcpy in ROM

0x40056f72: memcpy in ROM

Backtrace: 0x420b6000:0x3fcbf2d0 0x40387fda:0x3fcbf2f0 0x403881d1:0x3fcbf340 0x4003f4bd:0x3fcbf360 |<-CORRUPTED
0x420b6000: ieee80211_crypto_decap at ??:?

0x40387fda: sta_input at ??:?

0x403881d1: sta_rx_cb at ??:?

0x4003f4bd: ppRxPkt in ROM

My code:

`static void audio_detect_task(void *arg)
{
ESP_LOGI(TAG, "Detection task");
static afe_vad_state_t local_state;
static uint8_t frame_keep = 0;

bool detect_flag = false;

esp_mn_state_t mn_state = ESP_MN_STATE_DETECTING;
esp_afe_sr_data_t *afe_data = arg;

int afe_chunksize = afe_handle->get_fetch_chunksize(afe_data);
char *mn_name = esp_srmodel_filter(models, ESP_MN_PREFIX, ESP_MN_ENGLISH);
printf("multinet:%s\n", mn_name);
esp_mn_iface_t *multinet = esp_mn_handle_from_name(mn_name);
model_iface_data_t *model_data = multinet->create(mn_name, 6000);
int mu_chunksize = multinet->get_samp_chunksize(model_data);
esp_mn_commands_update_from_sdkconfig(multinet, model_data); // Add speech commands from sdkconfig
assert(mu_chunksize == afe_chunksize);
afe_handle->disable_wakenet(afe_data);


while (true) {
    if (NEED_DELETE && xEventGroupGetBits(g_sr_data->event_group)) {
        multinet->clean(model_data);
        xEventGroupSetBits(g_sr_data->event_group, DETECT_DELETED);
        vTaskDelete(g_sr_data->handle_task);
        vTaskDelete(NULL);
    }
    afe_fetch_result_t *res = afe_handle->fetch(afe_data);
    if (!res || res->ret_value == ESP_FAIL) {
        ESP_LOGW(TAG, "AFE Fetch Fail");
        continue;
    }

    if (manul_detect_flag) {
        pause_flag = true;
        detect_flag = true;
        if (manul_detect_flag) {
            manul_detect_flag = false;
            sr_result_t result = {
                .wakenet_mode = WAKENET_DETECTED,
                .state = ESP_MN_STATE_DETECTING,
                .command_id = 0,
            };
            xQueueSend(g_sr_data->result_que, &result, 0);
        }
        frame_keep = 0;
        multinet->clean(model_data);
        g_sr_data->afe_handle->disable_wakenet(afe_data);
        ESP_LOGI(TAG, LOG_BOLD(LOG_COLOR_GREEN) "AFE_FETCH_CHANNEL_VERIFIED, channel index: %d\n", res->trigger_channel_id);
    }

    if (false == pause_flag) {
        mn_state = multinet->detect(model_data, res->data);

        if (mn_state == ESP_MN_STATE_DETECTED) {
            app_sr_start_once();
        }
    }

    if (true == detect_flag) {

        if (local_state != res->vad_state) {
            local_state = res->vad_state;
            if (AFE_VAD_SILENCE != local_state) {
                ESP_LOGW(TAG, "%s, frame:%d", "silence", frame_keep);
            }
            frame_keep = 0;
        } else {
            frame_keep++;
        }

        if ((100 == frame_keep) && (AFE_VAD_SILENCE == res->vad_state)) {
            ESP_LOGW(TAG, "vad Time out");
            sr_result_t result = {
                .wakenet_mode = WAKENET_NO_DETECT,
                .state = ESP_MN_STATE_TIMEOUT,
                .command_id = 0,
            };
            xQueueSend(g_sr_data->result_que, &result, 0);
            g_sr_data->afe_handle->enable_wakenet(afe_data);
            pause_flag = false;
            detect_flag = false;
            continue;
        }
    }
}

if (model_data) {
    multinet->destroy(model_data);
    model_data = NULL;
}

/* Task never returns */
printf("detect exit\n");
vTaskDelete(NULL);

}`

@github-actions github-actions bot changed the title [Help] I'm trying to use the words multinet to run app_sr_start_once() by disabling wakenet, in the example chatgpt_demo [Help] I'm trying to use the words multinet to run app_sr_start_once() by disabling wakenet, in the example chatgpt_demo (AEGHB-368) Sep 1, 2023
@espressif2022
Copy link
Collaborator

I'm not sure about the crash reason.
But after wakeup, it'll save the audio to the buffer, did you delete this step for test?

@ESP-Mars
Copy link
Collaborator

ESP-Mars commented Nov 9, 2023

Temporarily closed due to the extended period of time with no response. Should you have additional questions or concerns, don't hesitate to reopen the issue.

@ESP-Mars ESP-Mars closed this as completed Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants