一、su-03t语音模块的配置和使用
1.su-03t语音模块介绍
su-03t 是一款低成本、低功耗、小体积的离线语音识别模组,能快速应用于智能家居,各类智能小家电,86 盒,玩具,灯具等需要语音操控的产品。通过串口通信,可以实现SU-03T模块和开发板的交互。
2.定制语音模块SDK
定制官网智能公元/AI产品零代码平台
进入官网后选择su-03t
产品类型选择一路开关,选择纯离线方案和su-03t模组,产品名称自定,语言选择中文。
将B6、B7引脚配置为串口,并设置波特率115200.
配置自定义唤醒词和回复
自定义命令词
添加控制指令
最后点击发布版本,等待半小时下载SDK包。
3.烧录SDK和串口调试验证
打开下载后的SDK,打开如图所示工具
使用usb转ttl模块连接su-03t并插入电脑,最后点击烧录(烧不进去,重新上电)
最后打开串口调试助手,设置波特率,进行语音测试。
二、ADB的安装和使用
1.ADB介绍
安卓调试桥(ADB – Android Debug Brige)是一个客户端-服务器(CS)端程序。其中客户端是用来操作的电脑,服务端是 Android 设备。ADB 也是 Android SDK 中的一个工具,可以直接操作管理 Android 模拟器或者真实的 Android 设备,也就是Android程序的debug工具。
2.香橙派zero2w使用adb连接手机
a.打开手机的usb调试选项
b.安装adb
sudo apt-get install -y adb
c.测试adb是否连接到手机
adb devices
adb shell
3.所用到的adb命令
上滑屏幕
adb shell input swipe 540 1300 540 500 100
下滑屏幕
adb shell input swipe 540 500 540 1300 100
双击屏幕
adb shell "seq 3|while read i; do input rap 350 1050 & input tap 350 1050 &sleep 0.05;done;"
声音加
adb shell input keyevent 24
声音减
adb shell input keyevent 25
锁屏
adb shell input keyevent 26
三、代码整合
#include <stdio.h>
#include <string.h>
#include <wiringPi.h>
#include <wiringSerial.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
int fd;
int main ()
{
fd = serialOpen("/dev/ttyAS5",115200);
if (fd < 0){
printf("serial open error\n");
return -1;
}
if (wiringPiSetup () == -1){
perror("wiringPi setup");
return -1;
}
char cnt;
/* 主线程,接收数据 */
while(1){
cnt = serialGetchar(fd);
printf("receive -> %#x\n",cnt);
switch (cnt)
{
case 0x1a:
system("adb shell input swipe 540 500 540 1300 100");
break;
case 0x2b:
system("adb shell input swipe 540 1300 540 500 100");
break;
case 0x3c:
system("adb shell \"seq 3|while read i; do input rap 350 1050 & input tap 350 1050 &sleep 0.05;done;\"");
break;
case 0x4d:
system("adb shell input keyevent 24");
break;
case 0x5e:
system("adb shell input keyevent 25");
break;
case 0x6f:
system("adb shell input keyevent 26");
break;
}
}
}
四、功能验证
gcc douyin.c -lwiringPi -lpthread #编译
sudo ./a.out