stm32 uses voice recognition and broadcast to intelligently control led lights

stm32 uses voice recognition and broadcast to intelligently control led lights


I wrote an article on speech recognition last time, but that module uses serial port for communication. This time I want to talk about another identification and broadcast module. Compared with the last one, this module has more functions, and of course, the price is more expensive. Both the identification module and the broadcast module are transmitted by IIC, so this time, the two IICs on the stm32f103c8t6 control board are PB6, PB7 and PB10, PB11. The main function of this article is to make the recognition module recognize the corresponding words according to the spoken instructions, make corresponding actions, and use the broadcast module to say whether the corresponding actions are completed. Here I just simply control the led lights, of course you can also control other things, such as household appliances and so on.
The voice recognition module has three modes, cyclic mode: the module is always in the voice recognition state; password mode: voice recognition is performed when a password is detected; button mode: when the button is pressed, it is in the voice recognition mode, and the module does not have an onboard button. Set the key detection program through the main control board. After detecting the key, send the key mode start command through I2C. The key mode can be defined by any key.
The speech template module supports the synthesis of any Chinese and English texts, and can use four encoding methods: GB2312, GBK, BIG5 and UNICODE. The amount of text per composition can be up to 4K bytes. The module analyzes the text, and the chip can correctly identify and process the text in the format of common numbers, numbers, time, date, weights and measures symbols, etc. according to the built-in text matching rules; for general polyphonic words, it can also be correct according to its context. Judging the reading method; in addition, for texts containing both Chinese and English, the mixed reading of Chinese and English can be realized. Supports a variety of control commands such as synthesizing text, stopping synthesizing, pausing synthesizing, resuming synthesizing, status query, etc. You can set the broadcast mode of the corresponding letters, such as letter pronunciation, word pronunciation, etc., and you can also broadcast Chinese through Hanyu Pinyin by setting. There are multiple built-in speakers, and the corresponding speakers can be selected for voice playback through settings. The speech speed, intonation, and volume of the voice broadcast can be set. The module also has other special broadcast settings such as number symbols.

Next, the pictures and links of the two modules are given respectively.
Speech recognition module (essentially LD3320)
Link: Speech Recognition Module
insert image description here
Voice Broadcasting Module There are other routines. The wiring of the above two modules is also relatively simple, as follows: Speech recognition module ------------- Speech synthesis broadcast module IIC1 ----------------- -------IIC2 VCC->MCU 5V --------VCC->MCU 5V SCL->MCU PB6 ------SCL->MCU PB10 SDA->MCU PB7 --- ---SDA->MCU PB11 GND->MCU GND ----GND->MCU GND The effect video is attached below:

insert image description here








stm32 voice recognition and broadcast intelligent control led lights

Then attach the main program:

#include "stm32f10x.h"
#include "bsp_i2c.h"
#include "bsp_usart1.h"
#include  "led.h"
/*
语音识别模块			语音合成播报模块
IIC1				IIC2
VCC->单片机5V		VCC->单片机5V	
SCL->单片机PB6		SCL->单片机PB10
SDA->单片机PB7		SDA->单片机PB11
GND->单片机GND		GND->单片机GND
*/

int main(void)
{
    
    
	u8 result = 0xff;
	LED_Init();		  	//初始化与LED连接的硬件接口
	//I2C初始化
	I2C_Bus_Init();
	NVIC_Configuration();
	USARTx_Config();
	
#if 1
	I2C_ByteWrite(ASR_CLEAR_ADDR,0x40);//清除掉电保存区,录入前需要清除掉电保存区
	LD3320_delay(150000);//flash擦除时间较长,需要较长的延时
	I2C_ByteWrite(ASR_MODE_ADDR,0x01);//设置检测模式;
	AsrAddWords(0,"xiao ya"); 	
	AsrAddWords(4,"kai deng");   
    AsrAddWords(5,"guan deng");

#endif
	I2C_ByteWrite(ASR_REC_GAIN,0x45);  //识别的灵敏
	RGB_Set(255,255,255);
	LD3320_delay(10000);//flash擦除时间较长,需要较长的延时
	RGB_Set(0,0,0);
	
	SetVolume(10);		
	SetReader(Reader_XiaoYan);
	while(1)
	{
    
    	
		I2C_BufferRead(ASR_RESULT,&result,1);
		printf("result = %d\n",result);
		if(result==0)
		{
    
    
		speech_text("[x1]sound204",GB2312);
	while(GetChipStatus() != ChipStatus_Idle)
	{
    
    
	  delay(50);
	}
		}
		if(result==4)
		{
    
    
		GPIO_ResetBits(GPIOA,GPIO_Pin_1);		  //给PA1置0
		speech_text("灯已经打开",GB2312);
	while(GetChipStatus() != ChipStatus_Idle)
	{
    
    
	  delay(50);
	}
		}
		if(result==5)
		{
    
    
		GPIO_SetBits(GPIOA,GPIO_Pin_1);		  //给PA1置1
		speech_text("灯已经关闭",GB2312);
	while(GetChipStatus() != ChipStatus_Idle)
	{
    
    
	  delay(50);
	}
		}		
		LD3320_delay(10000);	
	}
				
}

/*********************************************END OF FILE**********************/

If you want more detailed information, you can check it at the end of the article.
The relevant procedures and information are attached below:
stm32 voice recognition and broadcast intelligent control led light related procedures and information
Personally think the above information is very detailed! ! !
I will send you the message email below the code, and I will send it to you as soon as possible. If you have any questions, you can comment below!

Guess you like

Origin blog.csdn.net/weixin_44069765/article/details/113835168