diff --git a/rk3308/aispeech-2mic-32bit/RkLunch.sh b/rk3308/aispeech-2mic-32bit/RkLunch.sh index 5e16855..1a3a3bb 100755 --- a/rk3308/aispeech-2mic-32bit/RkLunch.sh +++ b/rk3308/aispeech-2mic-32bit/RkLunch.sh @@ -1,7 +1,9 @@ +amixer cset name='vad switch' 1 + echo 0x60 0x40ff0050 > /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 ln -s /oem/aispeech_softap_lite /data/aispeech_softap_lite diff --git a/rk3308/aispeech-2mic-32bit/dds_client/aimakefile b/rk3308/aispeech-2mic-32bit/dds_client/aimakefile index 82d10ef..f6aeeff 100755 --- a/rk3308/aispeech-2mic-32bit/dds_client/aimakefile +++ b/rk3308/aispeech-2mic-32bit/dds_client/aimakefile @@ -9,7 +9,7 @@ LOCAL_SRC_FILES += ./example/main.c LOCAL_MODULE := dui_$(MIC_TYPE) LOCAL_CFLAGS := -Wall -O2 -LOCAL_CFLAGS += -DSAVE_AUDIO +#LOCAL_CFLAGS += -DSAVE_AUDIO ifeq ($(MIC_TYPE), fespa) LOCAL_CFLAGS += -DWAKEUP_FESPA else ifeq ($(MIC_TYPE), fespl) diff --git a/rk3308/aispeech-2mic-32bit/dds_client/components/dui/dui_major_minor_multiple.o b/rk3308/aispeech-2mic-32bit/dds_client/components/dui/dui_major_minor_multiple.o index 067692e..b2f1230 100644 Binary files a/rk3308/aispeech-2mic-32bit/dds_client/components/dui/dui_major_minor_multiple.o and b/rk3308/aispeech-2mic-32bit/dds_client/components/dui/dui_major_minor_multiple.o differ diff --git a/rk3308/aispeech-2mic-32bit/dds_client/components/fsm/dui_fsm.o b/rk3308/aispeech-2mic-32bit/dds_client/components/fsm/dui_fsm.o index 7873f77..29bb31a 100644 Binary files a/rk3308/aispeech-2mic-32bit/dds_client/components/fsm/dui_fsm.o and b/rk3308/aispeech-2mic-32bit/dds_client/components/fsm/dui_fsm.o differ diff --git a/rk3308/aispeech-2mic-32bit/dds_client/components/json/cJSON.o b/rk3308/aispeech-2mic-32bit/dds_client/components/json/cJSON.o index 6e1658a..5d53080 100644 Binary files a/rk3308/aispeech-2mic-32bit/dds_client/components/json/cJSON.o and b/rk3308/aispeech-2mic-32bit/dds_client/components/json/cJSON.o differ diff --git a/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl b/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl index f60bf76..c4cd7a8 100755 Binary files a/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl and b/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl differ diff --git a/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl_record b/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl_record index c6f27d5..3a73cc4 100755 Binary files a/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl_record and b/rk3308/aispeech-2mic-32bit/dds_client/dui_fespl_record differ diff --git a/rk3308/aispeech-2mic-32bit/dds_client/example/main.c b/rk3308/aispeech-2mic-32bit/dds_client/example/main.c index 320f376..de41bc0 100755 --- a/rk3308/aispeech-2mic-32bit/dds_client/example/main.c +++ b/rk3308/aispeech-2mic-32bit/dds_client/example/main.c @@ -1,7 +1,31 @@ #include "dui.h" +#include "dui_msg.h" +#include "os_thread.h" +#include "os_queue.h" +#include "os_event_group.h" #include #include #include +#include + +#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) { FILE *fd = fopen(argv[1], "rb"); @@ -11,13 +35,40 @@ int main(int argc, char **argv) { fseek(fd, 0L, SEEK_SET); 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(); 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(); return 0; } diff --git a/rk3308/aispeech-2mic-32bit/dds_client/example/main.o b/rk3308/aispeech-2mic-32bit/dds_client/example/main.o index 67d1c3b..3490889 100644 Binary files a/rk3308/aispeech-2mic-32bit/dds_client/example/main.o and b/rk3308/aispeech-2mic-32bit/dds_client/example/main.o differ diff --git a/rk3308/aispeech-2mic-32bit/dds_client/example/main_vad.c b/rk3308/aispeech-2mic-32bit/dds_client/example/main_vad.c deleted file mode 100755 index 229aa16..0000000 --- a/rk3308/aispeech-2mic-32bit/dds_client/example/main_vad.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "dui.h" -#include "dui_msg.h" -#include "dui_thread.h" -#include "dui_queue.h" -#include -#include -#include -#include - -#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; -}