device:rockchip:rk3308:aispeech-2mic-32bit:support vad
Change-Id: I4072c5c84ed81818adb6b03dae55c0b4a5b42557 Signed-off-by: Sun ChuanHu <aaron.sun@rock-chips.com>
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
|
amixer cset name='vad switch' 1
|
||||||
|
|
||||||
echo 0x60 0x40ff0050 > /sys/kernel/debug/vad/reg
|
echo 0x60 0x40ff0050 > /sys/kernel/debug/vad/reg
|
||||||
echo 0x5c 0x000e2080 > /sys/kernel/debug/vad/reg
|
echo 0x5c 0x000e2080 > /sys/kernel/debug/vad/reg
|
||||||
|
|
||||||
arecord -D 2mic_loopback -c 8 -r 16000 -f S16_LE -d 1 -t raw /tmp/test.pcm
|
arecord -D 2mic_loopback -c 3 -r 16000 -f S16_LE -d 1 -t raw /tmp/test.pcm
|
||||||
rm /tmp/test.pcm
|
rm /tmp/test.pcm
|
||||||
|
|
||||||
ln -s /oem/aispeech_softap_lite /data/aispeech_softap_lite
|
ln -s /oem/aispeech_softap_lite /data/aispeech_softap_lite
|
||||||
|
|||||||
@ -9,7 +9,7 @@ LOCAL_SRC_FILES += ./example/main.c
|
|||||||
LOCAL_MODULE := dui_$(MIC_TYPE)
|
LOCAL_MODULE := dui_$(MIC_TYPE)
|
||||||
|
|
||||||
LOCAL_CFLAGS := -Wall -O2
|
LOCAL_CFLAGS := -Wall -O2
|
||||||
LOCAL_CFLAGS += -DSAVE_AUDIO
|
#LOCAL_CFLAGS += -DSAVE_AUDIO
|
||||||
ifeq ($(MIC_TYPE), fespa)
|
ifeq ($(MIC_TYPE), fespa)
|
||||||
LOCAL_CFLAGS += -DWAKEUP_FESPA
|
LOCAL_CFLAGS += -DWAKEUP_FESPA
|
||||||
else ifeq ($(MIC_TYPE), fespl)
|
else ifeq ($(MIC_TYPE), fespl)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +1,31 @@
|
|||||||
#include "dui.h"
|
#include "dui.h"
|
||||||
|
#include "dui_msg.h"
|
||||||
|
#include "os_thread.h"
|
||||||
|
#include "os_queue.h"
|
||||||
|
#include "os_event_group.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define EV_RECODER_CLOSE (1 << 0)
|
||||||
|
|
||||||
|
static os_event_group_handle_t event;
|
||||||
|
|
||||||
|
extern os_queue_handle_t user_listen_queue;
|
||||||
|
|
||||||
|
static void listen_cb(dui_msg_t *msg) {
|
||||||
|
dui_msg_t m;
|
||||||
|
int ret;
|
||||||
|
while (1) {
|
||||||
|
ret = os_queue_receive(user_listen_queue, &m);
|
||||||
|
if (ret == -1) break;
|
||||||
|
if (m.type == RECORDER_CMD_STOP) {
|
||||||
|
os_event_group_set_bits(event, EV_RECODER_CLOSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
FILE *fd = fopen(argv[1], "rb");
|
FILE *fd = fopen(argv[1], "rb");
|
||||||
@ -11,13 +35,40 @@ int main(int argc, char **argv) {
|
|||||||
fseek(fd, 0L, SEEK_SET);
|
fseek(fd, 0L, SEEK_SET);
|
||||||
fread(buf, 1, len, fd);
|
fread(buf, 1, len, fd);
|
||||||
|
|
||||||
|
event = os_event_group_create();
|
||||||
|
|
||||||
dui_library_init(buf, NULL);
|
dui_library_init(buf, listen_cb);
|
||||||
|
fclose(fd);
|
||||||
dui_start_recorder();
|
dui_start_recorder();
|
||||||
while (1) {
|
while (1) {
|
||||||
sleep(20);
|
int buf[64];
|
||||||
|
long frames;
|
||||||
|
while (1) {
|
||||||
|
struct timeval tv = {
|
||||||
|
.tv_usec = 50000
|
||||||
|
};
|
||||||
|
frames = -1;
|
||||||
|
fd = fopen("/sys/module/snd_soc_rockchip_vad/parameters/voice_inactive_frames", "r");
|
||||||
|
if (fd) {
|
||||||
|
if (fgets(buf, sizeof(buf), fd)) {
|
||||||
|
frames = atol(buf);
|
||||||
|
}
|
||||||
|
fclose(fd);
|
||||||
|
}
|
||||||
|
sleep(1);
|
||||||
|
printf("\n frames = %d", frames);
|
||||||
|
|
||||||
|
if (frames > 80000) {
|
||||||
|
dui_stop_recorder();
|
||||||
|
os_event_group_wait_bits(event, EV_RECODER_CLOSE, true, true);
|
||||||
|
system("echo 0 > /sys/module/snd_soc_rockchip_vad/parameters/voice_inactive_frames");
|
||||||
|
system("echo mem > /sys/power/state");
|
||||||
|
// usleep(30 * 1000);
|
||||||
|
dui_start_recorder();
|
||||||
|
}
|
||||||
|
select(0, NULL, NULL, NULL, &tv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dui_stop_recorder();
|
|
||||||
dui_library_cleanup();
|
dui_library_cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -1,69 +0,0 @@
|
|||||||
#include "dui.h"
|
|
||||||
#include "dui_msg.h"
|
|
||||||
#include "dui_thread.h"
|
|
||||||
#include "dui_queue.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define EV_RECODER_CLOSE (1 << 0)
|
|
||||||
|
|
||||||
static dui_event_group_handle_t event;
|
|
||||||
|
|
||||||
extern dui_queue_handle_t user_listen_queue;
|
|
||||||
|
|
||||||
static void listen_cb(dui_msg_t *msg) {
|
|
||||||
dui_msg_t m;
|
|
||||||
int ret;
|
|
||||||
while (1) {
|
|
||||||
ret = dui_queue_receive(user_listen_queue, &m);
|
|
||||||
if (ret == -1) break;
|
|
||||||
if (m.type == RECORDER_CMD_STOP) {
|
|
||||||
dui_event_group_set_bits(event, EV_RECODER_CLOSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
FILE *fd = fopen(argv[1], "rb");
|
|
||||||
fseek(fd, 0L, SEEK_END);
|
|
||||||
int len = ftell(fd);
|
|
||||||
char *buf = (char *)malloc(len + 1);
|
|
||||||
fseek(fd, 0L, SEEK_SET);
|
|
||||||
fread(buf, 1, len, fd);
|
|
||||||
|
|
||||||
event = dui_event_group_create();
|
|
||||||
|
|
||||||
dui_library_init(buf, listen_cb);
|
|
||||||
fclose(fd);
|
|
||||||
dui_start_recorder();
|
|
||||||
while (1) {
|
|
||||||
int buf[64];
|
|
||||||
long frames;
|
|
||||||
while (1) {
|
|
||||||
struct timeval tv = {
|
|
||||||
.tv_usec = 50000
|
|
||||||
};
|
|
||||||
frames = -1;
|
|
||||||
fd = fopen("/sys/module/snd_soc_rockchip_vad/parameters/voice_inactive_frames", "r");
|
|
||||||
if (fd) {
|
|
||||||
if (fgets(buf, sizeof(buf), fd)) {
|
|
||||||
frames = atol(buf);
|
|
||||||
}
|
|
||||||
fclose(fd);
|
|
||||||
}
|
|
||||||
if (frames > 80000) {
|
|
||||||
dui_stop_recorder();
|
|
||||||
dui_event_group_wait_bits(event, EV_RECODER_CLOSE, true, true);
|
|
||||||
system("echo 0 > /sys/module/snd_soc_rockchip_vad/parameters/voice_inactive_frames");
|
|
||||||
system("echo mem > /sys/power/state");
|
|
||||||
dui_start_recorder();
|
|
||||||
}
|
|
||||||
select(0, NULL, NULL, NULL, &tv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dui_library_cleanup();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user