用离线语音做个简易版智能家居系统(stm32)

最近课程项目要求自己动手做个东西,美其名曰融合平时所学,最后想了半天准备先做个低配版的天猫精灵,也算实现个小项目吧,目前实现了简单的语音交互,能播报温湿度以及感知环境光照的功能,当然还能控制一个小LED灯,之前还想做个红外学习,实现对于家电红外的控制,最后因为模块的硬件没跟上失败了,先埋个坑吧,有时间再继续更新。其实主要还是靠各个模块,感觉就像在搭建电子积木,难度不大,可以用来作为stm32入门练手的一个好项目。

  • *总体思路

总结的思路其实相当简单,作为信息输入,主要有三个部分:环境感知、语音识别、红外接收。其中,环境感知主要由温湿度传感器和光敏传感器实现,获取当前环境的温湿度和光强数据并发送到单片机实现环境感知功能。语音识别功能基于集成语音模块,识别当前环境的语音。当检测到命令语句时,将指定的数据发送到解码,并将编码信息发送到单片机进行处理。

[En]

The summary idea is actually quite simple, as information input, there are three main parts: environmental awareness, speech recognition, infrared reception. Among them, the environmental perception is mainly realized by the temperature and humidity sensor and the photosensitive sensor, and the data of the current environmental temperature, humidity and light intensity are obtained and sent to the single-chip microcomputer to realize the environmental perception function. The speech recognition function is based on the integrated speech module, which recognizes the speech of the current environment. When the command statement is detected, the specified data will be sent to decoding, and the coding information will be sent to the single-chip microcomputer for processing.

而输出部分同样分为三部分:LED灯控制、语音播报、红外发射。LED灯的亮灭主要通过继电器,从而实现对于环境光照的调节功能;语音播报基于语音模块以及扬声器实现,可实现简单的语句回复、事件提醒以及播报当前温湿度数据等功能;红外发射模块可将单片机传输来的数据进行编码后发射对应红外信号。

用的模块大体如下:

用离线语音做个简易版智能家居系统(stm32)

(图片来自购买界面,入侵删除)

[En]

(the picture comes from the purchase interface, intruding and deleting)

电源与温湿度传感器、光敏就不多介绍了,但是这个LD3322语音模块还是很好用的,网页设置好后等着下载固件就好,很方便,串口、变量播报也很方便。网页开发也挺方便的。本来以为难度都在语音识别上,结果这个模块直接就把我难度大幅降低,也不贵。

用离线语音做个简易版智能家居系统(stm32)
  • *程序

程序来说,难度不大,开两个串口,一个用于和语音模块通信,一个用于接收红外解码信息,温湿度传感器和光照传感器的数据读取例程也很多,加上继电器控制LED灯,把这些整合起来,写点逻辑关系,基本上就可以了。

用离线语音做个简易版智能家居系统(stm32)
  • *实现过程

重点介绍了语音模块、语音输入命令,可以分为三类。

[En]

Focus on the voice module, voice input commands, can be divided into three categories.

第一类:简单离线回复:不需要进行其他操作,直接回复设置好了的语句就行。比如设置了当听到了”你好”时回复”你好”,这部分由LD3322语音独立就能完成。

第二类:控制类:即”开灯”、”关灯”这类的命令词,这时候需要语音模块通过串口发送指定的数据至单片机,让单片机进行对应的操作,同时播放特定的回复语句,例如:”好的,这就打开台灯”。

第三类:单片机触发:当环境光线变暗时,可以打开灯,将指定的数据发送到语音模块。语音模块播送“探测微弱的环境光线,为您打开灯”。或者由单片微型计算机将温度发送到语音模块,然后它就可以播送诸如“现在的温度是26摄氏度”之类的东西(这在当时被发现时是令人惊叹的)。

[En]

The third category: single-chip microcomputer trigger: when the ambient light is dark, you can turn on the light and send the specified data to the voice module. The voice module broadcasts “detect dim ambient light, turn on the lamp for you”. Or the single-chip microcomputer sends the temperature to the voice module, and then it can broadcast things such as “the temperature is now 26 degrees Celsius” (which was amazing when it was discovered at the time).

  • 效果

练习时制作一段视频,并直接在课程报告中写下文字描述。

[En]

Make a video when you have practice, and write down the text description in the course report directly now.

由于本次项目成果通过语音实现,项目成果难以展示,因此只能通过总结性文字进行举例。下面利于”人”与”机”的对话来进行成果展示:
语音交互
通过语音模块,可以实现基本的语音控制和语音交互功能。但由于语音模块是离线模块,只能实现少量的定句识别和定句回复。比如,在设定了一句固定的话后:“今年党的生日是几岁?”机器:“今年是2021年,中国共产党百年诞辰。”

[En]

Through the voice module, the basic voice control and voice interaction functions can be realized. However, because the speech module is an offline module, it can only achieve a small number of fixed sentence recognition and fixed sentence reply. For example, after setting a fixed sentence: “how old is the birthday of the Party this year?” Machine: “this year is 2021, the centenary of Communist Party of China.”

照明灯具控制
通过语音模块与单片机的交互,可以实现控制功能,语音控制LED灯的开关,其原理为语音模块识别到对应的固定语音后,发送对应的数据给单片机,单片机进行LED灯的开关,即可实现该功能。
环境感知
通过温湿度传感器以及光敏传感器,可以较为准确地读取到当前环境下的温湿度数据以及光照强度数据。因此,通过单片机可实现智能控制以及播报。例如在较暗的环境下,单片机会自动将LED灯开启;在较明亮的情况下,可以实现自动关闭LED灯。当然,人的指令的优先级高于自动执行的优先级,因此,在人的语音指令控制下,也可以实现明亮环境亮灯、昏暗环境关灯的功能,从而实现人在不同情境下的不同要求。
此外,由于语音助手具有可变播报功能,单片机还可以通过语音指令读取温湿度传感器数据,并通过串口发送给语音模块,由语音模块播报。以实现对当前环境的准确描述。

[En]

In addition, because the voice assistant has the function of variable broadcast, the single-chip microcomputer can also read the temperature and humidity sensor data through the voice command and send it to the voice module through the serial port, which is broadcast by the voice module. to achieve an accurate description of the current environment.

红外学习
通过串口通信,将控制信号传输到红外编码模块,由红外发射机发射特定频率的脉冲,达到遥控空调的目的。控制原理图如下图1所示。在整个过程中,只有语音作为唯一的控制信号来控制三个常见的家具,基本可以实现简单的智能家居控制器的功能。

[En]

Through serial communication, the control signal can be transmitted to the infrared coding module, and then the infrared transmitter can emit pulses of specific frequency to achieve the purpose of remote control air conditioning. The control schematic is shown in figure 1 below. In the whole process, only voice is used as the only control signal to control three common furniture, which can basically realize the function of simple intelligent home controller.

课程项目做得很匆忙,代码很乱,不规范,我们不会先挂上的。如果朋友想要,请留言,我会转给你的。

[En]

The course project is done in a hurry, and the code is very messy and non-standard, so we won’t put it up first. if a friend wants it, leave a message and I’ll send it.

Original: https://blog.csdn.net/weixin_47104677/article/details/121508825
Author: 北辰远x
Title: 用离线语音做个简易版智能家居系统(stm32)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/515244/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球