標(biāo)題:
STM32+SYN7318進(jìn)行語音識別后回傳帶命令I(lǐng)D后為啥無法再次語音識別,求大神解救小白
[打印本頁]
作者:
騎蝸牛闖地球
時間:
2019-4-16 11:26
標(biāo)題:
STM32+SYN7318進(jìn)行語音識別后回傳帶命令I(lǐng)D后為啥無法再次語音識別,求大神解救小白
#include "system.h"
#include "SysTick.h"
#include "led.h"
#include "usart.h"
#include "string.h"
void kaishishibie()
{
char sbuf[]={0xD4,0xDA,0xE0,0xCF,0x21};
u16 i=0;
char len;
char head[8];
len=strlen(sbuf);
head[0]=0xFD;
head[1]=0x00;
head[2]=len+2;
head[3]=0x15;//語音識別模式
head[4]=0x03;//詞典庫
head[5]=0x09;//喚醒名稱
head[6]=0x01;
head[7]=0x01;
for (i=0;i<8;i++)
{
USART_SendData(USART3,head[i]);
while(USART_GetFlagStatus(USART3,USART_FLAG_TXE) != SET);
}
for (i=0;i<len;i++)
{
USART_SendData(USART3,sbuf[i]);
while(USART_GetFlagStatus(USART3,USART_FLAG_TXE) != SET);
}
}
void delay_nms(u16 time)
{ u16 i=0;
while(time--)
{
i=12000;
while(i--) ;
}
}
int main()
{
u8 state=0,ml=0;
USART3_Init(115200);
SysTick_Init(72);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
LED_Init();
led1=0;
led2=0;
led3=0;
while (1)
{
kaishishibie();
q=0;
while (1)
{
if(q==1)
{
q=0;
if(bufer[2]==0x01)
{
switch (bufer[3])
{
case 0x4A:state=0;break;//模塊初始化成功回傳
case 0x41:state=0;break;//接收到正確的命令幀回傳
case 0x45:state=1;break;//接收失敗,收到不能識別的命令幀
case 0x4F:state=1;break;//模塊空閑狀態(tài)回傳
case 0x42:state=0;break;//處于語音識別或者語音喚醒狀態(tài)
case 0x49:state=0;break;//處于MP3播放
case 0x4B:state=0;break;//更新詞典
case 0x4E:state=0;break;//語音合成播放
case 0x21:state=0;break;//喚醒成功
case 0x22:state=0;break;//喚醒內(nèi)部錯誤
case 0x23:state=0;break;//自定義喚醒名稱設(shè)置成功
case 0x24:state=0;break;//自定義喚醒名稱設(shè)置失敗
case 0x31:state=1;break;//詞典更新成功
case 0x32:state=1;break;//詞典更新失敗
case 0x03:state=1;break;//用戶靜音超時
case 0x04:state=1;break;//用戶語音超時
case 0x05:state=1;break;//識別拒識
case 0x06:state=1;break;//識別拒識
case 0x07:state=1;break;//識別內(nèi)部錯誤
case 0x99:state=1;break;//查詢模塊版本回傳
}
}
else if(bufer[4]==0x06)
{
state=1;//識別成功,帶命令I(lǐng)D
ml=bufer[8];//將命令I(lǐng)D給ML
}
else if(bufer[4]==0x04)
{
state=1;//識別成功,無命令I(lǐng)D
}
if(state==1)
{
break;
}
}
switch(ml)
{
case 1:led4=0;led6=1;break;
case 2:led4=1;led6=1;break;
case 3:led5=0;led6=1;break;
case 4:led5=1;led6=1;break;
default :led6=0;
}
}
memset(bufer,0,sizeof (bufer));
}
}
復(fù)制代碼
全部資料51hei下載地址:
語音識別.7z
(176.94 KB, 下載次數(shù): 18)
2019-4-16 16:23 上傳
點(diǎn)擊文件名下載附件
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1