代码拉取完成,页面将自动刷新
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_wn_iface.h"
#include "esp_wn_models.h"
#include "model_path.h"
#include "string.h"
#include "hiesp.h"
#include "hilexin.h"
void app_main(void *arg)
{
srmodel_list_t *models = esp_srmodel_init("model");
char *model_name = esp_srmodel_filter(models, ESP_WN_PREFIX, "hilexin");
esp_wn_iface_t *wakenet = (esp_wn_iface_t*)esp_wn_handle_from_name(model_name);
model_iface_data_t *model_data = wakenet->create(model_name, DET_MODE_95);
int audio_chunksize = wakenet->get_samp_chunksize(model_data) * sizeof(int16_t);
int16_t *buffer = (int16_t *) malloc(audio_chunksize);
unsigned char* data = NULL;
size_t data_size = 0;
int chunks = 0;
if (strstr(model_name, "hiesp") != NULL) {
data = (unsigned char*)hiesp;
data_size = sizeof(hiesp);
printf("wake word: %s, size:%d\n", "hiesp", data_size);
} else if(strstr(model_name, "hilexin") != NULL) {
data = (unsigned char*)hilexin;
data_size = sizeof(hilexin);
printf("wake word: %s, size:%d\n", "hilexin", data_size);
}
while (1) {
if ((chunks + 1)*audio_chunksize <= data_size) {
memcpy(buffer, data + chunks * audio_chunksize, audio_chunksize);
} else {
break;
}
wakenet_state_t state = wakenet->detect(model_data, buffer);
if (state == WAKENET_DETECTED) {
printf("Detected\n");
}
chunks ++;
}
wakenet->destroy(model_data);
vTaskDelete(NULL);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。