import RPi.GPIO as GPIO
import record
import time
import csv
from myThread import MyThread
import sound
import snowboydecoder
import sys
import signal
import record_monitor as recordMonitor
import LED
import threading
# ===================================================
# 实验控制量
#
# ==============================================
# ==============================================
# 数据记录线程
def record_csv(dd):
D11 = 17
l = 22
f = "/sys/bus/w1/devices/28-01201cd1596c/w1_slave"
print("开始检测数据")
i = 0
a = {}
try:
while True:
time.sleep(1)
a['时间'] = time.strftime("%Y%m%d %X", time.localtime())
result = record.D11_temp_humidity(D11)
if result:
a['温度1'] = record.temperature(f)
x, y = result
a['温度2'] = y
a['湿度'] = x
a['亮度'] = record.light(l)
with open("htl.csv", "a", encoding="utf-8") as file:
writer = csv.writer(file)
print(a)
for i in a:
writer.writerow(i)
except:
GPIO.cleanup()
# ===================================================
# 语音对话模块
def signal_handler(signal, frame):
global interrupted
interrupted = True
def interrupt_callback():
global interrupted
return interrupted
def wake_up():
global detector
model = 'snowboy.pmdl' # 唤醒词为 SnowBoy
# capture SIGINT signal, e.g., Ctrl+C
signal.signal(signal.SIGINT, signal_handler)
# 唤醒词检测函数,调整sensitivity参数可修改唤醒词检测的准确性
detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
print('Listening... please say wake-up word:SnowBoy')
# main loop
# 回调函数 detected_callback=snowboydecoder.play_audio_file
# 修改回调函数可实现我们想要的功能
detector.start(detected_callback=callbacks, # 自定义回调函数
interrupt_check=interrupt_callback,
sleep_time=0.03)
# 释放资源
detector.terminate()
def callbacks():
global detector
# 语音唤醒后,提示ding两声
snowboydecoder.play_audio_file()
snowboydecoder.play_audio_file()
# 关闭snowboy功能
detector.terminate()
# 开启语音识别
# recordMonitor.monitor()
sound_result = s_sound(0)
print("语音识别结果\n")
print(sound_result)
# 打开snowboy功能
wake_up() # wake_up —> monitor —> wake_up 递归调用
def s_sound(dd):
flag = 'y'
# while flag.lower() == 'y':
# print('请输入数字选择语言:')
# devpid = input('1536:普通话(简单英文),1537:普通话(有标点),1737:英语,1637:粤语,1837:四川话\n')
devpid = 1536
sound.my_record()
TOKEN = sound.getToken(sound.HOST)
speech = sound.get_audio(sound.FILEPATH)
result = sound.speech2text(speech, TOKEN, int(devpid))
print(result)
return result
# if type(result) == str:
# openbrowser(result.strip(','))
# flag = input('Continue?(y/n):')
# ==============================================
# 人脸识别模块
# ==============================================
# def loop(x):
# time.sleep(x)
# print("第一个进程,停止结束")
#
# def loop2(x):
# for i in range(2):
# time.sleep(x)
# print("停止:", i)
# print("第二个进程,停止结束")
# 线程控制
funcs = [s_sound,record_csv]
def main():
nfuncs = range(len(funcs))
threads = []
for i in nfuncs:
t = MyThread(funcs[i], 0, funcs[i].__name__)
threads.append(t)
for i in nfuncs:
threads[i].start()
# for i in nfuncs:
# threads[i].join()
# print(threads[i].getResult())
print("all over!")
if __name__ == "__main__":
main()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
功能: 实现了语音控制的功能 \1. 主要负责通过语音交流实现对家电的控制。 \2. 在接受使用者的语音调节指令时,进行数据采集存放到数据库中,再进行训练。为自动调整屋内环境做准备。提供个性化的智能管理。 光照强度控制: \1. 控制对象:灯具 \2. 由光照传感器接受光照强度,将信息传递给智能管家,由智能管家进行分析处理,自动调整灯具的亮度,构建一个适宜的光照环境。 室内温度控制: \1. 控制对象:空调或地暖 由温度传感器接受室内温度,将信息传递给智能管家,由智能管家进行分析处理,自动调整空调或地暖的温度设定,构建一个适宜的温度环境。 构建一个基于深度神经网络的终身学习智能家居系统,实现收集用户日常生活习惯数据,并自主学习,创建一个个性化的智能家居系统。
资源推荐
资源详情
资源评论
收起资源包目录
基于深度神经网络的终身学习智能家居系统.zip (30个子文件)
raspberry-pie-master
read.py 933B
myThread.py 560B
a.py 1KB
data_timers.py 2KB
app.py 2KB
templates
Web_Control.html 11KB
index.html 1KB
video_handler.py 922B
thread_run.py 4KB
cap.py 4KB
__pycache__
video_handler.cpython-39.pyc 1KB
myThread.cpython-39.pyc 1KB
cap.cpython-39.pyc 2KB
static
images
光照弱.png 7KB
灯泡.png 8KB
雪花.png 9KB
温度低.png 8KB
树莓派.png 12KB
湿度高.png 10KB
灯泡亮.png 7KB
湿度低.png 10KB
闭眼睛.png 6KB
光照过强.png 7KB
睁眼.png 7KB
温度高.png 7KB
湿度.png 10KB
bg.png 1.86MB
光照.png 6KB
温度.png 7KB
默认用户.png 5KB
共 30 条
- 1
资源评论
博士僧小星
- 粉丝: 1934
- 资源: 5894
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功