device:rockchip:aispeech-4mic-32bit:support vad
Change-Id: I28a99191f6df65cc2824010367e91a97e88a8aa2 Signed-off-by: Sun ChuanHu <aaron.sun@rock-chips.com>
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
arecord -D vad -c 8 -r 16000 -f S16_LE -d 1 -t raw /tmp/test.pcm
|
||||
rm /tmp/test.pcm
|
||||
amixer cset name='vad switch' 1
|
||||
echo 0x60 0x40ff0050 > /sys/kernel/debug/vad/reg
|
||||
echo 0x5c 0x000e2080 > /sys/kernel/debug/vad/reg
|
||||
|
||||
arecord -D 4mic_loopback -c 5 -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
|
||||
ln -s /oem/wifi_monitor.sh /data/
|
||||
ln -s /oem/dds_client /data/dds_client
|
||||
|
||||
@ -1206,8 +1206,8 @@ static int dui_parse_cfg(const char *cfg) {
|
||||
|
||||
int dui_library_init(const char *cfg, user_listen_cb listen) {
|
||||
#ifdef SAVE_AUDIO
|
||||
input_fd = fopen("/tmp/1.pcm", "wb");
|
||||
output_fd = fopen("/tmp/2.pcm", "wb");
|
||||
input_fd = fopen("/userdata/1.pcm", "wb");
|
||||
output_fd = fopen("/userdata/2.pcm", "wb");
|
||||
#endif
|
||||
if (0 != dui_parse_cfg(cfg)) return -1;
|
||||
os_log_init(NULL);
|
||||
|
||||
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_msg.h"
|
||||
#include "os_thread.h"
|
||||
#include "os_queue.h"
|
||||
#include "os_event_group.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.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) {
|
||||
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;
|
||||
}
|
||||
|
||||
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