LDV7语音识别模块资料分享
LDV7语音识别模块资料分享
·
一、模块参数
型号:YS-LDV7
名称:一体化语音识别模块
规格:43*29.7MM
供电电压:5V (内部工作电压 3.3V)
待机电流:30MA
识别时电流:45MA
IO 口输出:高电平为 3.3V
通信方式:串口通信(5V TTL 电平,不可直接接 RS232、RS485)
单片机参数:型号–>STC11L08XE 、flash–>8k、SRAM–>1280、eeprom–>32k
识别词条个数:50 句
工作温度:-20 至 60℃
二、例程代码
#include "config.h"
/************************************************************************************/
// nAsrStatus 用来在main主程序中表示程序运行的状态,不是LD3320芯片内部的状态寄存器
// LD_ASR_NONE: 表示没有在作ASR识别
// LD_ASR_RUNING: 表示LD3320正在作ASR识别中
// LD_ASR_FOUNDOK: 表示一次识别流程结束后,有一个识别结果
// LD_ASR_FOUNDZERO: 表示一次识别流程结束后,没有识别结果
// LD_ASR_ERROR: 表示一次识别流程中LD3320芯片内部出现不正确的状态
/***********************************************************************************/
uint8 idata nAsrStatus=0;
void MCU_init();
void ProcessInt0(); //识别处理函数
void delay(unsigned long uldata);
void User_handle(uint8 dat);//用户执行操作函数
void Delay200ms();
void Led_test(void);//单片机工作指示
uint8_t G0_flag=DISABLE;//运行标志,ENABLE:运行。DISABLE:禁止运行
sbit LED=P4^2;//信号指示灯
/***********************************************************
* 名 称: void main(void)
* 功 能: 主函数 程序入口
* 入口参数:
* 出口参数:
* 说 明:
* 调用方法:
**********************************************************/
void main(void)
{
uint8 idata nAsrRes;
uint8 i=0;
Led_test();
MCU_init();
LD_Reset();
UartIni(); /*串口初始化*/
nAsrStatus = LD_ASR_NONE; // 初始状态:没有在作ASR
#ifdef TEST
PrintCom("一级口令:小杰\r\n"); /*text.....*/
PrintCom("二级口令:1、代码测试\r\n"); /*text.....*/
PrintCom(" 2、开发板验证\r\n"); /*text.....*/
PrintCom(" 3、开灯\r\n"); /*text.....*/
PrintCom(" 4、关灯\r\n"); /*text.....*/
PrintCom(" 5、北京\r\n"); /*text.....*/
PrintCom(" 6、上海\r\n"); /*text.....*/
PrintCom(" 7、广州\r\n"); /*text.....*/
#endif
while(1)
{
switch(nAsrStatus)
{
case LD_ASR_RUNING:
case LD_ASR_ERROR:
break;
case LD_ASR_NONE:
{
nAsrStatus=LD_ASR_RUNING;
if (RunASR()==0) /* 启动一次ASR识别流程:ASR初始化,ASR添加关键词语,启动ASR运算*/
{
nAsrStatus = LD_ASR_ERROR;
}
break;
}
case LD_ASR_FOUNDOK: /* 一次ASR识别流程结束,去取ASR识别结果*/
{
nAsrRes = LD_GetResult(); /*获取结果*/
User_handle(nAsrRes);//用户执行函数
nAsrStatus = LD_ASR_NONE;
break;
}
case LD_ASR_FOUNDZERO:
default:
{
nAsrStatus = LD_ASR_NONE;
break;
}
}// switch
}// while
}
/***********************************************************
* 名 称: LED灯测试
* 功 能: 单片机是否工作指示
* 入口参数: 无
* 出口参数:无
* 说 明:
**********************************************************/
void Led_test(void)
{
LED=~ LED;
Delay200ms();
LED=~ LED;
Delay200ms();
LED=~ LED;
Delay200ms();
LED=~ LED;
Delay200ms();
LED=~ LED;
Delay200ms();
LED=~ LED;
}
/***********************************************************
* 名 称: void MCU_init()
* 功 能: 单片机初始化
* 入口参数:
* 出口参数:
* 说 明:
* 调用方法:
**********************************************************/
void MCU_init()
{
P0 = 0xff;
P1 = 0xff;
P2 = 0xff;
P3 = 0xff;
P4 = 0xff;
P1M0=0XFF; //P1端口设置为推挽输出功能,即提高IO口驱动能力,从驱动继电器模块工作
P1M1=0X00;
LD_MODE = 0; // 设置MD管脚为低,并行模式读写
IE0=1;
EX0=1;
EA=1;
}
/***********************************************************
* 名 称: 延时函数
* 功 能:
* 入口参数:
* 出口参数:
* 说 明:
* 调用方法:
**********************************************************/
void Delay200us() //@22.1184MHz
{
unsigned char i, j;
_nop_();
_nop_();
i = 5;
j = 73;
do
{
while (--j);
} while (--i);
}
void delay(unsigned long uldata)
{
unsigned int j = 0;
unsigned int g = 0;
while(uldata--)
Delay200us();
}
void Delay200ms() //@22.1184MHz
{
unsigned char i, j, k;
i = 17;
j = 208;
k = 27;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
/***********************************************************
* 名 称: 中断处理函数
* 功 能:
* 入口参数:
* 出口参数:
* 说 明:
* 调用方法:
**********************************************************/
void ExtInt0Handler(void) interrupt 0
{
ProcessInt0();
}
/***********************************************************
* 名 称:用户执行函数
* 功 能:识别成功后,执行动作可在此进行修改
* 入口参数: 无
* 出口参数:无
* 说 明:
**********************************************************/
void User_handle(uint8 dat)
{
//UARTSendByte(dat);//串口识别码(十六进制)
if(0==dat)
{
G0_flag=ENABLE;
LED=0;
PrintCom("收到\r\n"); /*text.....*/
}
else if(ENABLE==G0_flag)
{
G0_flag=DISABLE;
LED=1;
switch(dat) /*对结果执行相关操作,客户可删除Printcom 串口输出语句替换为其他需要控制的代码*/
{
case CODE_DMCS: /*命令“测试”*/
PrintCom("“代码测试”命令识别成功\r\n"); /*text.....*/
break;
case CODE_KFBYZ: /*命令“全开”*/
PrintCom("“开发板验证”命令识别成功\r\n"); /*text.....*/
break;
case CODE_KD: /*命令“复位”*/
PrintCom("“开灯”命令识别成功\r\n"); /*text.....*/
break;
case CODE_GD: /*命令“复位”*/
PrintCom("“关灯”命令识别成功\r\n"); /*text.....*/
break;
case CODE_BJ: /*命令“复位”*/
PrintCom("“北京”命令识别成功\r\n"); /*text.....*/
break;
case CODE_SH: /*命令“复位”*/
PrintCom("“上海”命令识别成功\r\n"); /*text.....*/
break;
case CODE_GZ: /*命令“复位”*/
PrintCom("“广州”命令识别成功\r\n"); /*text.....*/
break;
default:PrintCom("请重新识别发口令\r\n"); /*text.....*/break;
}
}
else
{
PrintCom("请说出一级口令\r\n"); /*text.....*/
}
}
完整例程下载:LDV7语音识别模块--(口令模式).zip: https://url83.ctfile.com/f/45573183-1380525647-5489ac?p=7526 (访问密码: 7526)
更多推荐
所有评论(0)