项目:基于百度API智能语音家居控制系统

 

目录

开发平台/开发环境:

        windows 10、Linux、arm cortex A9(Exynos 4412)、ubuntu20.04、zigebee通信、摄像头外设、cortex-M0;

项目模块:

        摄像头模块;qt界面及语音识别模块;qt客户端模块;服务器模块;

项目描述:

        qt客户端可以通过连接服务器后,通过语音识别,确定想要的功能,可以通过服务器显示摄像头内的视频内容,也可以通过服务器的串口通信去操控cortex M0的LED灯,风扇,蜂鸣器,服务器可以通过串口通信实时地获得cortex M0上的温度,湿度,光照信息,并发送给客户端,qt客户端还可以获取天气预报信息或者打开某一个应用。

具体代码:

        1.串口模块:

serial.h:

 serial.c:

 摄像头:

 camera.h:

 camera.c

 摄像头服务器:

camera_server.h:

camera_server.c:

服务器:

server.h

 server.c

主函数

main.c

下面是QT的模块:使用的模式是:QT widgets applicantion;使用的基类是:widget

 录音和设置语音文件:对应下面audio.c

audio.h

http请求百度api获取请求数据:

http.h

处理http请求数据并再次请求百度api再次返回的json:

speech.h

通过http协议获取天气 :

weather.h

 界面操作:

widget.h

audio.cpp

http.cpp

 main.cpp

speech.cpp

weather.cpp

widget.cpp

 ui界面:

 演示:


开发平台/开发环境:

        windows 10、Linux、arm cortex A9(Exynos 4412)、ubuntu20.04、zigebee通信、摄像头外设、cortex-M0;

arm cortex A9(Exynos 4412):内部使用裁剪后的Linux系统来搭建服务器。

ubuntu20.04:使用arm-linux-gcc工具编译成可以在arm架构芯片上执行的程序。

zigbee协调节点板块与A9板使用串口通信,ZigBee 模块主要实现的是数据的透传的工作,一个 ZigBee 节点接收服务器的消息无线转到ZigBee 的另外一个节点,另外一个节点把数据发送给终端设备,完成操作。同时也可以反过来,是终端设备的环境信息。我使用的CC2530 的单片机。它是一款完全兼容 8051 的内核,同时支持 IEEE 802.15.4协议的无线射频的单片机。这个项目主要是使用 ZigBee 提供的协议栈来进行开发。使用了其中的函数接口来完成项目需求的应用程序。


数据终端采集:
数据采集模块使用的是 ARM 系列的 Cortex-M0 芯片,在这个芯片的基础之上。分别外接了以下几个设备。有温湿度、光照、三轴传感器与 RFID 射频模块。还是风扇、LED、蜂鸣器、OLED 硬件。同时集成第 94 页了 RS485、CAN 总线。在这个项目中,使用到了温湿度、光照、三轴传感器获取当前的环境信息,发送到ZigBee 的节点。从 ZigBee 的节点接收命令通过风扇、LED、蜂鸣器来模拟家中的电器设备。在这个模块中使用了 ARM 开发的一些流程,如配置寄存器让硬件工作。一些总线设备的使用,如 SPI、I2C。还有中断的机制和定时器的使用,如本项目中启用了一个 32 位的定时器来做延时操作。

项目模块:

        摄像头模块;qt界面及语音识别模块;qt客户端模块;服务器模块;

项目描述:

        qt客户端可以通过连接服务器后,通过语音识别,确定想要的功能,可以通过服务器显示摄像头内的视频内容,也可以通过服务器的串口通信去操控cortex M0的LED灯,风扇,蜂鸣器,服务器可以通过串口通信实时地获得cortex M0上的温度,湿度,光照信息,并发送给客户端,qt客户端还可以获取天气预报信息或者打开某一个应用。

具体代码:

        1.串口模块:

serial.h:

#ifndef SERIAL_H
#define SERIAL_H#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <termios.h>
#include <error.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
int serial_set(char *path);
int serial_write(int fd);
int serial_close(int fd);
int serial_ctrl(int fd,char *p);
int serial_getdata(int fd);#endif

 serial.c:

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <termios.h>
#include <sys/types.h>
#include <string.h>#define N 36
int serial_set(char *path)
{struct termios options;/*struct termios {tcflag_t  c_iflag;//输入标志tcflag_t  c_oflag;//输出标志tcflag_t  c_lflag;// 本地标志tcflag_t  c_cc[NCCS];//控制字符};	*/int fd = open(path,O_RDWR | O_NOCTTY | O_NDELAY);//打开串口if(-1 == fd){perror("open error");return -1;}if(-1 == fcntl(fd,F_SETFL,0)){printf("fcntl error");return -1;}cfsetispeed(&options,B115200);cfsetospeed(&options,B115200);options.c_cflag |= CLOCAL;  //修改控制模式,使得能够从串口中读取输入数据  options.c_cflag |= CREAD;  options.c_oflag &= ~(ONLCR | OCRNL);options.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);options.c_iflag &= ~(ICRNL | INLCR);options.c_iflag &= ~(IXON | IXOFF | IXANY);//不使用流控制options.c_cflag &= ~CRTSCTS;options.c_cflag |= CS8;options.c_cflag &= ~CSTOPB;options.c_cflag &= ~PARENB;options.c_iflag &= ~INPCK;tcsetattr(fd, TCSANOW, &options); //TCSANOW更改立即发生return fd;
}
int serial_close(int fd) //关闭串口
{if (close(fd)) {perror("serial close error");return -1;}return 0;
}
int serial_ctrl(int fd,char *p)
{  unsigned char envbuf[36]={0,0x08,0x24,0x00};if(strncmp(p,"light_on",8)==0){//envbuf[]  = {0xdd,id,24,00,命令}//发送命令开灯envbuf[0]=0xdd;envbuf[4]=0x00;   //开灯命令if(write(fd,envbuf,36)<0){perror("write");return -1;}printf("控制:%x %x %x %x %x\n",envbuf[0],envbuf[1],envbuf[2],envbuf[3],envbuf[4]);}else if(strncmp(p,"light_off",9)==0){//发送命令关灯envbuf[0]=0xdd;envbuf[4]=0x01; //关灯if(write(fd,envbuf,36)<0){perror("write");return -1;}printf("控制:%x %x %x %x %x\n",envbuf[0],envbuf[1],envbuf[2],envbuf[3],envbuf[4]);}else if(strncmp(p,"dshi_on",9)==0){//发送命令打开蜂鸣器envbuf[0]=0xdd;envbuf[4]=0x02;  if(write(fd,envbuf,36)<0){perror("write");return -1;}printf("控制:%x %x %x %x %x\n",envbuf[0],envbuf[1],envbuf[2],envbuf[3],envbuf[4]);}else if(strncmp(p,"dshi_off",10)==0){//发送命令关闭蜂鸣器envbuf[0]=0xdd;envbuf[4]=0x03;if(write(fd,envbuf,36)<0){perror("write");return -1;}printf("控制:%x %x %x %x %x\n",envbuf[0],envbuf[1],envbuf[2],envbuf[3],envbuf[4]);}else if(strncmp(p,"feng_on",7)==0){printf("feng_on\n");//发送命令打开风扇envbuf[0]=0xdd;envbuf[4]=0x04;printf("控制:%x %x %x %x %x\n",envbuf[0],envbuf[1],envbuf[2],envbuf[3],envbuf[4]);if(write(fd,envbuf,36)<0){perror("write");return -1;}}else if(strncmp(p,"feng_off",8)==0){//发送命令关闭风扇envbuf[0]=0xdd;envbuf[4]=0x08;if(write(fd,envbuf,36)<0){perror("write");return -1;}printf("控制:%x %x %x %x %x\n",envbuf[0],envbuf[1],envbuf[2],envbuf[3],envbuf[4]);}//        memset(p, 0, 32); //清空bufreturn 0;
}

 摄像头:

 camera.h:

#ifndef _CAMERA_H
#define _CAMERA_H#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/videodev2.h>
#include <string.h>
#include <sys/mman.h>#define pwd "/dev/video0"
#define pwd2 "/dev/video1"
#define c_count 4unsigned char *mmps[c_count];
unsigned long mmpsize[c_count];int camera_init();
int camera_star(int fd);
//出队,采集数据
int dqbuf(int fd,int index);
//入队,归还数据
int qbuf(int fd,int index);
int camera_stop(int fd);#endif

 camera.c

#include "camera.h"int camera_init()
{int ret;//v4l2_std_id std;//struct v4l2_format fmt;//使用非阻塞方式打开摄像头设备int camera_fd = open(pwd,O_RDWR,0);if(camera_fd < 0){camera_fd = open(pwd2,O_RDWR | O_NONBLOCK,0);} if(camera_fd < 0){printf("摄像头打开失败\n");return -1;} printf("成功打开摄像头\n");//使用ioctl函数对设备的io通道进行管理//检查当前视频设备支持的标准,使用VIDIOC_QUERYSTD
/*	do{ret = ioctl(camera_fd,VIDIOC_QUERYSTD,&std); }while(-1 == ret && errno == EAGAIN);switch (std){case V4L2_STD_NTSC:printf("视频标准为NTSC\n");	break;	case V4L2_STD_PAL:printf("视频标准为PAL\n");break;}*///设置视频捕获格式bzero(&fmt,sizeof(fmt));//摄像头的数据流类型,必须为V4L2_BUF_TYPE_VIDEO_CAPTUREfmt.type					= V4L2_BUF_TYPE_VIDEO_CAPTURE;fmt.fmt.pix.width			= 640; //必须为16的倍数fmt.fmt.pix.height		= 480; //必须为16的倍数//视频数据存储类型YUYV 或者 RGBfmt.fmt.pix.pixelformat	= V4L2_PIX_FMT_MJPEG;fmt.fmt.pix.field			= V4L2_FIELD_INTERLACED;if(-1 == ioctl(camera_fd,VIDIOC_S_FMT,&fmt)){printf("设置视频捕获格式失败\n");return -2;}//为视频捕获分配内存struct v4l2_requestbuffers req;bzero(&req,sizeof(req));req.count	= c_count;req.type		= V4L2_BUF_TYPE_VIDEO_CAPTURE;req.memory	= V4L2_MEMORY_MMAP;if(-1 == ioctl(camera_fd,VIDIOC_REQBUFS,&req)){printf("分配内存出错\n");return -3;}printf("分配内存成功\n");int i;struct v4l2_buffer buffer;for(i=0;i<c_count;i++){buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;buffer.memory = V4L2_MEMORY_MMAP;buffer.index = i;if(0 > ioctl(camera_fd,VIDIOC_QUERYBUF,&buffer)){printf("取出映射地址出错\n");return -1;}//映射mmps[i] = mmap(NULL,buffer.length,PROT_READ|PROT_WRITE,MAP_SHARED,camera_fd,buffer.m.offset);mmpsize[i] = buffer.length;if((void *)-1 == mmps[i]){printf("映射地址时出错\n");return -2;}//入队操作if(0 > ioctl(camera_fd,VIDIOC_QBUF,&buffer)){printf("入队失败\n");return -3;} }printf("摄像头初始化成功...\n");return camera_fd;
}
int camera_star(int fd)
{//开始采集enum v4l2_buf_type type=V4L2_BUF_TYPE_VIDEO_CAPTURE;if(0 > ioctl(fd,VIDIOC_STREAMON,&type)){perror("采集失败:");return -1;} printf("开始采集...\n");return 0;
}
//出队,采集数据
int dqbuf(int fd,int index)
{struct v4l2_buffer buffer;bzero(&buffer,sizeof(buffer));buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;buffer.memory=V4L2_MEMORY_MMAP;buffer.index = index;if(0 > ioctl(fd,VIDIOC_DQBUF,&buffer)){printf("读取视频内容失败\n");perror("read");return -1;}return 0;
}//入队,归还数据
int qbuf(int fd,int index)
{struct v4l2_buffer buffer;bzero(&buffer,sizeof(buffer));buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;buffer.memory=V4L2_MEMORY_MMAP;buffer.index = index;if(0 > ioctl(fd,VIDIOC_QBUF,&buffer)){printf("入队失败\n");return -1;}return 0;
}
/*
int getpic(int fd)
{//映射队列空间到用户空间VIDIOC_QUERYBUF,VIDIOC_QBUFstruct v4l2_buffer buffer;int i=0;while(1){//出对,获得采集数据bzero(&buffer,sizeof(buffer));buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;buffer.memory=V4L2_MEMORY_MMAP;buffer.index = i;if(0 > ioctl(fd,VIDIOC_DQBUF,&buffer)){printf("读取视频内容失败\n");perror("read");return -4;}//测试图片FILE *file = fopen("1.jpg","w+");fwrite(mmps[buffer.index],buffer.length,1,file);fclose(file);//入对if(0 > ioctl(fd,VIDIOC_QBUF,&buffer)){printf("入队失败\n");return -5;}i++;i=i%4;}return 0;
}
*/
int camera_stop(int fd)
{//停止采集int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;if(0 > ioctl(fd,VIDIOC_STREAMOFF,&type)){printf("停止摄像头错误\n");return -1;}printf("停止摄像头\n");return 0;
}
/*
int main()
{int camera_fd = camera_init();if(0 > camera_fd){return -1;}if(0 > camera_star(camera_fd)){return -1;}int i=0;while(1){if(0 > dqbuf(camera_fd,i))//出队,从mmps映射的地址读取数据{return -1;}FILE *file = fopen("1.jpg","w+");fwrite(mmps[i],mmpsize[i],1,file);fclose(file);if(0 > qbuf(camera_fd,i))//入队{return -1;}i++;i%=4;}//getpic(camera_fd);camera_stop(camera_fd);return 0;
}
*/

 摄像头服务器:

camera_server.h:

#ifndef  _CAMERA__SERVER_H
#define  _CAMERA__SERVER_H#include "camera.h"
#include <pthread.h>
#include <stdio.h>
#include <sys/types.h> 
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
#include <pthread.h>int camera_all();
void * camera_close_thread(void * fd);
void * camera_send_thread(void * fd);
void * camera_thread(void * fd);#endif

camera_server.c:

#include "camera_server.h"int camera_fd = -1;
int socket_fd = -1;
char * pic_buf [4] = {NULL,NULL,NULL,NULL};
long unsigned int pic_len = 0;
int camera_i=0;void * camera_thread(void * fd)
{printf("开始摄像头线程\n");if(0 > camera_star(camera_fd)){pthread_exit(NULL);}while(1){if(0 > dqbuf(camera_fd,camera_i))//出队,从mmps映射的地址读取数据{pthread_exit(NULL);}if(NULL == pic_buf[0]){pic_len= mmpsize[camera_i];pic_buf[0] = (char *)malloc(pic_len);pic_buf[1] = (char *)malloc(pic_len);pic_buf[2] = (char *)malloc(pic_len);pic_buf[3] = (char *)malloc(pic_len);}bzero(pic_buf[camera_i],pic_len);memcpy(pic_buf[camera_i],mmps[camera_i],pic_len);if(0 > qbuf(camera_fd,camera_i))//入队{pthread_exit(NULL);}camera_i++;camera_i%=4;}pthread_exit(NULL);
}
void * camera_send_thread(void * fd)
{int connfd = *(int *)fd;int j=0;char len[10]={0};char buf[10]={0};while(1){if(0>=read(connfd,buf,sizeof(buf))){printf("客户端退出\n");break;}else{sprintf(len,"%ld",pic_len);send(connfd,len,sizeof(len),0);j=camera_i-1;if(-1 == j){j = 3;}send(connfd,pic_buf[j],pic_len,0);}}printf("发送结束\n");pthread_exit(NULL);}void * camera_close_thread(void * fd)
{while(1){char cmd[16];bzero(cmd,sizeof(cmd));scanf("%s",cmd);getchar();if(0 == strcmp(cmd,"quit")){printf("摄像头服务器关闭。。。\n");break;}}camera_stop(camera_fd);exit(0);
}
int camera_all()
//int main()
{//创建套接字socket_fd = socket(AF_INET,SOCK_STREAM,0);if(-1 == socket_fd){perror("socket");return -1;}printf("摄像头网络套接字创建成功\n");//优化2:解决地址冲突int opt = 1;	setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt));//填充ip,端口,协议等struct sockaddr_in ser_addr = {.sin_family			=	AF_INET,.sin_port				=	htons(8888),//端口号1024-49151.sin_addr.s_addr		=	inet_addr("0.0.0.0")};//绑定ip和端口等信息int ret = bind(socket_fd,(struct sockaddr *) &ser_addr,sizeof(ser_addr));if(-1 == ret){perror("bind");return -1;}printf("绑定成功\n");	//建立监听ret = listen(socket_fd,4);if(-1 == ret){perror("listen");return -1;}printf("建立监听。。。\n");struct sockaddr_in accept_addr;bzero(&accept_addr,sizeof(accept_addr));socklen_t addrlen = sizeof(accept_addr);//初始化摄像头camera_fd = camera_init();if(0 > camera_fd){pthread_exit(NULL);}pthread_t tid1,tid2,tid3;	if(-1 == pthread_create(&tid1,NULL,camera_thread,NULL)){printf("摄像头线程启动失败\n");return -1;}pthread_detach(tid1);while(1){	 int connfd = accept(socket_fd,(struct sockaddr *)&accept_addr,&addrlen);if(-1 == pthread_create(&tid2,NULL,camera_close_thread,NULL)){printf("关闭摄像头线程启动失败\n");return -1;}pthread_detach(tid2);	printf("客户端连接成功\n");printf("IP:%s,port:%d,addrlen:%d\n",inet_ntoa(accept_addr.sin_addr),accept_addr.sin_port,addrlen);printf("启动摄像头发送线程\n");if(-1 == pthread_create(&tid3,NULL,camera_send_thread,(void *)&connfd)){printf("摄像头线程启动失败\n");return -1;}pthread_detach(tid3);	}
}

服务器:

server.h

#ifndef SER_H
#define SER_H#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/ip.h>
#include<netinet/in.h>
#include<stdio.h>
#include<stdlib.h>
#include<arpa/inet.h>
#include<pthread.h>
#include<string.h>
#include<unistd.h>
#include<semaphore.h>
#define N 16
#define SIZE 36typedef struct sockaddr_in SA_in;typedef struct sockaddr  SA;typedef unsigned short uint_16_t;
typedef unsigned int uint_32_t;int tcp_init(const char *ip,const int port ,const int backlog);int getorder(const int connfd);
void *sendvideo(void *arg);
void *serial_cntl(void *arg);
void *senddata_cli(void *arg);#endif

 server.c

#include "camera_server.h"int camera_fd = -1;
int socket_fd = -1;
char * pic_buf [4] = {NULL,NULL,NULL,NULL};
long unsigned int pic_len = 0;
int camera_i=0;void * camera_thread(void * fd)
{printf("开始摄像头线程\n");if(0 > camera_star(camera_fd)){pthread_exit(NULL);}while(1){if(0 > dqbuf(camera_fd,camera_i))//出队,从mmps映射的地址读取数据{pthread_exit(NULL);}if(NULL == pic_buf[0]){pic_len= mmpsize[camera_i];pic_buf[0] = (char *)malloc(pic_len);pic_buf[1] = (char *)malloc(pic_len);pic_buf[2] = (char *)malloc(pic_len);pic_buf[3] = (char *)malloc(pic_len);}bzero(pic_buf[camera_i],pic_len);memcpy(pic_buf[camera_i],mmps[camera_i],pic_len);if(0 > qbuf(camera_fd,camera_i))//入队{pthread_exit(NULL);}camera_i++;camera_i%=4;}pthread_exit(NULL);
}
void * camera_send_thread(void * fd)
{int connfd = *(int *)fd;int j=0;char len[10]={0};char buf[10]={0};while(1){if(0>=read(connfd,buf,sizeof(buf))){printf("客户端退出\n");break;}else{sprintf(len,"%ld",pic_len);send(connfd,len,sizeof(len),0);j=camera_i-1;if(-1 == j){j = 3;}send(connfd,pic_buf[j],pic_len,0);}}printf("发送结束\n");pthread_exit(NULL);}void * camera_close_thread(void * fd)
{while(1){char cmd[16];bzero(cmd,sizeof(cmd));scanf("%s",cmd);getchar();if(0 == strcmp(cmd,"quit")){printf("摄像头服务器关闭。。。\n");break;}}camera_stop(camera_fd);exit(0);
}
int camera_all()
//int main()
{//创建套接字socket_fd = socket(AF_INET,SOCK_STREAM,0);if(-1 == socket_fd){perror("socket");return -1;}printf("摄像头网络套接字创建成功\n");//优化2:解决地址冲突int opt = 1;	setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt));//填充ip,端口,协议等struct sockaddr_in ser_addr = {.sin_family			=	AF_INET,.sin_port				=	htons(8888),//端口号1024-49151.sin_addr.s_addr		=	inet_addr("0.0.0.0")};//绑定ip和端口等信息int ret = bind(socket_fd,(struct sockaddr *) &ser_addr,sizeof(ser_addr));if(-1 == ret){perror("bind");return -1;}printf("绑定成功\n");	//建立监听ret = listen(socket_fd,4);if(-1 == ret){perror("listen");return -1;}printf("建立监听。。。\n");struct sockaddr_in accept_addr;bzero(&accept_addr,sizeof(accept_addr));socklen_t addrlen = sizeof(accept_addr);//初始化摄像头camera_fd = camera_init();if(0 > camera_fd){pthread_exit(NULL);}pthread_t tid1,tid2,tid3;	if(-1 == pthread_create(&tid1,NULL,camera_thread,NULL)){printf("摄像头线程启动失败\n");return -1;}pthread_detach(tid1);while(1){	 int connfd = accept(socket_fd,(struct sockaddr *)&accept_addr,&addrlen);if(-1 == pthread_create(&tid2,NULL,camera_close_thread,NULL)){printf("关闭摄像头线程启动失败\n");return -1;}pthread_detach(tid2);	printf("客户端连接成功\n");printf("IP:%s,port:%d,addrlen:%d\n",inet_ntoa(accept_addr.sin_addr),accept_addr.sin_port,addrlen);printf("启动摄像头发送线程\n");if(-1 == pthread_create(&tid3,NULL,camera_send_thread,(void *)&connfd)){printf("摄像头线程启动失败\n");return -1;}pthread_detach(tid3);	}
}

主函数

main.c

#include "ser.h"
const char *ip="0";
const int port=7777;
const int backlog=5;int main(int argc, char *argv[])
{SA_in cli_addr;socklen_t cli_addr_len=sizeof(cli_addr);int sfd=tcp_init(ip,port,backlog);pthread_t camera_thread;pthread_create(&camera_thread,NULL,sendvideo,NULL); pthread_detach(camera_thread);while(1){int connfd=accept(sfd,(SA*)&cli_addr,&cli_addr_len);if(-1==connfd){perror("connect");return -1;}printf("客户端已连接\n");int ret=getorder(connfd);}
}

下面是QT的模块:使用的模式是:QT widgets applicantion;使用的基类是:widget

在.pro文件下要添加这几个模块 :

QT  += core gui network multimedia texttospeech

 录音和设置语音文件:对应下面audio.c

audio.h

#ifndef AUDIO_H
#define AUDIO_H#include <QObject>
#include <QAudioInput>
#include <QFile>
#include <QAudioDeviceInfo>
#include <QMessageBox>class audio : public QObject
{Q_OBJECT
public:explicit audio(QObject *parent = nullptr);void startRecord(QString filename);   //开始录音void stopRecord();                    //停止录音~audio();
signals:
public slots:private:QAudioInput *m_audioInput;           //录音对象QFile       *m_file;                 //
};
#endif // AUDIO_H

http请求百度api获取请求数据:

http.h

#ifndef HTTP_H
#define HTTP_H#include <QObject>
#include <QMap>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QEventLoop>
class http : public QObject
{Q_OBJECT
public:explicit http(QObject *parent = nullptr);bool postSyn(QString url, QMap<QString, QString> headerdata, QByteArray requestData, QByteArray &replydata);
signals:public slots:
};
#endif // HTTP_H

处理http请求数据并再次请求百度api再次返回的json:

speech.h

#ifndef SPEECH_H
#define SPEECH_H#include <QObject>
#include "http.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QHostInfo>
#include <QFile>
#include <QMessageBox>
#include <QIODevice>
//获取access_token相关
const QString baiduTokenUrl = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=(填写语音ai的id)&client_secret=(语音ai的秘钥)&";
const QString client_id = "(填写语音ai的id)";
const QString client_secret = "(语音ai的秘钥)";//语音识别相关
const QString baiduSpeechurl = "http://vop.baidu.com/server_api?dev_pid=1537&cuid=%1&token=%2"; //普通话测试class speech : public QObject
{Q_OBJECT
public:explicit speech(QObject *parent = nullptr);QString speechIdentify(QString filename);  //开始识别QString getJsonvalue(QByteArray ba,QString key);
signals:public slots:
private:QString  accessToken;
};
#endif // SPEECH_H

通过http协议获取天气 :

weather.h

#ifndef WEATHER_H
#define WEATHER_H#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QtTextToSpeech>class weather : QObject
{Q_OBJECT
public:explicit weather(QObject *parent = nullptr);QString processing_data(const int);void getweather(const QString);
private slots:void reply(QNetworkReply*);
private:QNetworkAccessManager *manager;QJsonObject obj;QTextToSpeech speak;};#endif // WEATHER_H

 界面操作:

widget.h

#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>#include <QMessageBox>#include <QMovie>#include <QLabel>#include <QBitmap>#include <QTcpSocket>#include <QDebug>#include <QUdpSocket>#include <QHostAddress>#include "audio.h"#include "speech.h"#include "weather.h"#include <QTimer>#include <string.h>#include <QTextToSpeech>#include <QVoice>#include <QProcess>namespace Ui {
class Widget;
}class Widget : public QWidget
{Q_OBJECTpublic:explicit Widget(QWidget *parent = 0);~Widget();private slots:void on_pushButton_4_clicked();void on_pushButton_clicked();void on_pushButton_3_clicked();void netConnected();void netConnected1();void disconnectcam();void disconnectserver();void read1();void sav1();void on_pushButton_2_clicked();void on_pushButton_6_clicked();void on_pushButton_5_clicked();void on_pushButton_7_clicked();void on_pushButton_8_clicked();void on_pushButton_9_clicked();void on_pushButton_10_clicked();void on_btn_speekin_pressed();void on_btn_speekin_released();void on_wtobtn_clicked();void on_wyesbtn_clicked();private:Ui::Widget *ui;QTcpSocket *socket;//QTcpSocket *camsocket;QTcpSocket *camsocket;QByteArray pbuf;QString ip;int port;int port1;QPixmap pixmap;QHostAddress saddr;quint16 sport;int state =1;int plen;audio Audiodevice;     //创建录音设备对象speech m_speech;QTimer *time;weather *wt;int day=0;QString addr;int flaglight = 1;int flagfeng = 1;int flagcurtain = 1;int flagdshi = 1;bool flagserver = false;QTextToSpeech speak;QProcess *p1,*p2;};#endif // WIDGET_H

audio.cpp

#include "audio.h"audio::audio(QObject *parent) : QObject(parent)
{}
void audio::startRecord(QString filename)
{// 判断本地设备是否支持该格式QAudioDeviceInfo audioDeviceInfo = QAudioDeviceInfo::defaultInputDevice();// 判断本地是否有录音设备;if (!audioDeviceInfo.isNull()){m_file = new QFile;m_file->setFileName(filename);m_file->open(QIODevice::WriteOnly | QIODevice::Truncate);// 设置音频文件格式;QAudioFormat format;// 设置采样频率;format.setSampleRate(16000);// 设置通道数;format.setChannelCount(1);// 设置每次采样得到的样本数据位值;format.setSampleSize(16);// 设置编码方法;format.setCodec("audio/pcm");// 设置采样字节存储顺序;//format.setByteOrder(QAudioFormat::LittleEndian);// 设置采样类型;//format.setSampleType(QAudioFormat::UnSignedInt);// 判断当前设备设置是否支持该音频格式(重点);if (!audioDeviceInfo.isFormatSupported(format)){format = audioDeviceInfo.nearestFormat(format);}// 创建录音对象;m_audioInput = new QAudioInput(format, this);//开始录音m_audioInput->start(m_file);}else{// 没有录音设备;QMessageBox::information(NULL, tr("Record"), tr("Current No Record Device"));}}void audio::stopRecord()
{//停止录音m_audioInput->stop();//关闭文件m_file->close();//删除文件对象delete m_file;  //删除只是删除了指针指向的内存空间,没有删除指针,需要将指针指为NULLm_file = NULL;}
audio::~audio()
{delete m_audioInput;delete m_file;
}

http.cpp

#include "http.h"http::http(QObject *parent) : QObject(parent)
{}bool http::postSyn( QString url, QMap<QString, QString> headerdata, QByteArray requestData, QByteArray &replydata)
{
//发送请求的对象QNetworkAccessManager manager;
//请求对象QNetworkRequest request;request.setUrl(url);QMapIterator<QString, QString> it(headerdata);  //迭代器while (it.hasNext())                            //遍历Map{it.next();request.setRawHeader(it.key().toLatin1(),it.value().toLatin1());}QNetworkReply *reply = manager.post(request, requestData) ;QEventLoop l;//一旦服务器返回,reply会发出信号connect(reply, &QNetworkReply::finished, &l, &QEventLoop::quit);l.exec();//死循环,reply发出信号, 结束循环if (reply != nullptr && reply->error() == QNetworkReply::NoError){replydata = reply->readAll(); //读取服务 器返回的数据qDebug() << replydata;return true;}else{qDebug() << "请求失败";return false;}
}

 main.cpp

#include "widget.h"
#include <QApplication>
#include <QMessageBox>int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;w.show();return a.exec();
}

speech.cpp

#include "speech.h"//构造函数
speech::speech(QObject *parent) : QObject(parent)
{}QString speech::speechIdentify(QString filename)
{//获取tokenQString tokenUrl = QString(baiduTokenUrl).arg(client_id).arg(client_secret);QMap<QString, QString> headers;headers.insert(QString("Content-Type"), QString("audio/pcm;rate=16000"));QByteArray requestdata;   //发送的内容QByteArray replydata;     //服务器返回的内容http httputil;bool success = httputil.postSyn(tokenUrl, headers, requestdata, replydata);if (success){QString key = "access_token";accessToken  = getJsonvalue(replydata, key);  //获取到access_token(通过json数据格式解析)}elsereturn "";//语言识别QString baiduSpeech = QString(baiduSpeechurl).arg(QHostInfo::localHostName()).arg(accessToken);//把文件 转化为QByteArrayQFile file;file.setFileName(filename);file.open(QIODevice::ReadOnly);requestdata =file.readAll();file.close();replydata.clear();//再次发起http请求bool result = httputil.postSyn(baiduSpeech, headers, requestdata, replydata);if (result){QString key = "result" ;QString text = getJsonvalue (replydata, key) ;return text;}else{QMessageBox::warning(NULL,"识别提示","识别失败");}return "";}QString speech::getJsonvalue(QByteArray ba, QString key)
{QJsonParseError parseError;QJsonDocument jsonDocument = QJsonDocument::fromJson(ba, &parseError);if(parseError.error == QJsonParseError::NoError){if(jsonDocument.isObject()){//jsonDocument转换成json对象QJsonObject jsonObj = jsonDocument.object() ;if (jsonObj.contains (key)){QJsonValue jsonVal = jsonObj.value(key);if (jsonVal.isString())//字符串{return jsonVal.toString();}else if (jsonVal.isArray()) //数组{QJsonArray arr = jsonVal.toArray(); //转换成JsonArrayQJsonValue jv = arr.at(0);          //获取第1个元素return jv. toString();}}}}return "";
}

weather.cpp

#include "weather.h"weather::weather(QObject *parent) : QObject(parent)
{manager = new QNetworkAccessManager(this);connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(reply(QNetworkReply*)));speak.setVolume(200);
}void weather::reply(QNetworkReply *rep)
{QByteArray data = rep->readAll();data = data.mid(29,data.length()-31);QJsonObject obj = QJsonDocument::fromJson(data).object();this->obj = obj;
}QString weather::processing_data(int day)
{QString data,date,weath,temp,wind;//fl,fx,high,low,type,data;if(!obj.contains("weather")){data = "未查询到天气";return data;}/*QJsonObject objp= obj.value("weather").toObject();if(!objp.contains("weather")){data = "未查询到昨天的天气";return data;}QJsonObject objp1= objp.value("weather").toObject();*//*if(-1 == day){if(!objp.contains("yesterday")){data = "未查询到昨天的天气";return data;}QJsonObject obj1 = objp.value("yesterday").toObject();date = obj1.value("date").toString();fl = obj1.value("fl").toString();fx = obj1.value("fx").toString();high = obj1.value("high").toString();low = obj1.value("low").toString();type = obj1.value("type").toString();data =      date + "\n"+   "风力 :" + fl + "\n"+   "风向 :" + fx + "\n"+   high + "\n"+   low + "\n"+   "天气  :" + type;speak.say(data);}*/if(day>=0 && day<=6){/*if(!objp1.contains("weather")){data = "未查询到今天及未来几天天气情况。";return data;}*/QJsonArray arr = obj.value("weather").toArray();QJsonObject today = arr.at(day).toObject();date = today.value("date").toString();weath = today.value("weather").toString();temp = today.value("temp").toString();wind = today.value("wind").toString();data =      date    + "\n"+   "天气:" + weath + "\n"+   "温度:" + temp + "\n"+   "风向:" + wind;/*date = today.value("date").toString();fl = today.value("weather").toString();fx = today.value("temp").toString();high = today.value("wind").toString();low = today.value("low").toString();type = today.value("type").toString();data =      date + "\n"+   "风力 :" + fl + "\n"+   "风向 :" + fx + "\n"+   high + "\n"+   low + "\n"+   "天气  :" + type;*/speak.say(data);}else{data = "超出范围";}return data;
}
void weather::getweather(const QString addr)
{//QString url ="http://wthrcdn.etouch.cn/weather_mini?city=" + addr;QString url ="https://query.asilu.com/weather/baidu/?city=${" + addr + "}&callback=weather";QNetworkRequest request;request.setUrl(QUrl(url));manager->get(request);
}

widget.cpp

#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
{ui->setupUi(this);p1 = new QProcess(this);p2 = new QProcess(this);this->setMinimumSize(QSize(1000, 600));this->setFixedSize( this->width (),this->height ());//固定窗口大小//设置按键的失能false 使能trueui->pushButton->setEnabled(false);ui->pushButton_3->setEnabled(false);ui->pushButton_2->setEnabled(false);ui->pushButton_6->setEnabled(false);ui->pushButton_7->setEnabled(false);ui->pushButton_8->setEnabled(false);ui->pushButton_10->setEnabled(false);//time = new QTimer;wt = new weather;addr = ui->lineaddr->text();wt->getweather(ui->lineaddr->text());ui->weathertext->setText(wt->processing_data(day));connect(ui->lineaddr,&QLineEdit::textChanged,this,[&](){wt->getweather(ui->lineaddr->text());day=0;ui->weathertext->setText(wt->processing_data(day));});//speak.setVoice(myvoice.at(1));speak.setVolume(200);//connect(time,&QTimer::timeout,this,[&](){});//time->start(2000);/*QMovie *mv = new QMovie(":/new/prefix1/bj2.gif");ui->label_5->setScaledContents(true);ui->label_5->setMovie(mv);mv->start();//label动图*/}Widget::~Widget()
{delete ui;
}void Widget::on_pushButton_4_clicked()//连接服务器
{ip=ui->lineEdit->text();port  =ui->lineEdit_2->text().toInt();socket=new QTcpSocket;connect(socket,&QTcpSocket::connected,this,&Widget::netConnected);connect(socket,&QTcpSocket::readyRead,this,&Widget::read1);connect(socket,&QTcpSocket::disconnected,this,&Widget::disconnectserver);socket->connectToHost(ip,port);//服务器端口套接字}void Widget::disconnectserver()
{socket->close();ui->label_12->setText("服务器已断开!");ui->lineEdit_gq->setText("0");ui->lineEdit_sd->setText("0");ui->lineEdit_wd->setText("0");ui->pushButton->setDisabled(true);ui->pushButton_8->setDisabled(true);ui->pushButton_10->setDisabled(true);ui->pushButton_2->setDisabled(true);ui->pushButton_6->setDisabled(true);ui->pushButton_4->setEnabled(true);flagserver = false;
}void Widget::on_pushButton_9_clicked()//udp连接摄像头
{//QString data = "connect";saddr=ui->lineEdit->text().toLatin1();//摄像头用的套接字sport =ui->lineEdit_3->text().toInt();camsocket=new QTcpSocket(this);//camsocket->writeDatagram(data.toLatin1(),saddr,sport);connect(camsocket,&QTcpSocket::readyRead,this,&Widget::sav1);connect(camsocket,&QTcpSocket::connected,this,&Widget::netConnected1);connect(camsocket,&QTcpSocket::disconnected,this,&Widget::disconnectcam);camsocket->connectToHost(saddr,sport);camsocket->write("ok");
}void Widget::disconnectcam()
{camsocket->close();ui->label_11->setText("摄像头已断开!");ui->label_4->setText("摄像头已经断开");ui->pushButton_7->setDisabled(true);ui->pushButton_9->setEnabled(true);
}//用户自定义的槽,服务器连接成功过后使能和失能按键
void Widget::netConnected()
{ui->label_12->setText("服务器连接成功");flagserver = true;qDebug()<<"ip:"<<ip<<"port:"<<port;ui->pushButton->setEnabled(true);ui->pushButton_3->setEnabled(true);ui->pushButton_2->setEnabled(true);ui->pushButton_6->setEnabled(true);ui->pushButton_8->setEnabled(true);ui->pushButton_4->setEnabled(false);ui->pushButton_10->setEnabled(true);}void Widget::netConnected1()
{  //ui->label_11->setText("摄像头连接成功");ui->pushButton_7->setEnabled(true);qDebug()<<"ip:"<<ip<<"port1:"<<port1;ui->pushButton_9->setEnabled(false);
}void Widget::read1()
{char buf[36]={0};socket->read(buf,36);/*char *i = nullptr;i=(char *)&data;evnir.temperature =*(unsigned short *)i;evnir.humidity =*(unsigned short *)(i+sizeof(unsigned short));evnir.illuminance = *(unsigned int *)(i+2*sizeof(unsigned short));*///sprintf(buf,"t:%d h:%d i:%d",&evnir.temperature,&evnir.humidity,&evnir.illuminance);int guang=0,wen=0,shi=0;sscanf(buf,"t:%d h:%d i:%d",&wen,&shi,&guang);//qDebug()<<data.toStdString().data()<<":"<<wen<<":"<<shi<<":"<<guang;qDebug()<<buf<<":"<<wen<<":"<<shi<<":"<<guang;/*if(guang>180){socket->write("chuang_on");ui->label_5->setStyleSheet("border-image: url(:/di1.2.jpg);");ui->pushButton_8->setText("目前\n  窗帘 关闭");}if(guang<=180){socket->write("chuang_off");ui->label_5->setStyleSheet("border-image: url(:/new/prefix1/di1.JPG);");ui->pushButton_8->setText("目前\n  窗帘 打开");}*/ui->lineEdit_gq->setText(QString::number(guang));ui->lineEdit_sd->setText(QString::number(shi));ui->lineEdit_wd->setText(QString::number(wen));
}
void Widget::sav1()
{//接收图片switch (state){case 1:plen=camsocket->read(10).toInt();camsocket->write("ok");state=2;break;case 2:if(camsocket->bytesAvailable()<plen)return;pbuf = camsocket->read(plen);pixmap.loadFromData(pbuf);ui->label_4->setPixmap(pixmap);state=1;camsocket->write("ok");break;}}void Widget::on_pushButton_clicked()
{socket->disconnectFromHost();socket->close();ui->label_12->setText("服务器已断开!");ui->pushButton->setEnabled(false);ui->pushButton_3->setEnabled(false);ui->pushButton_2->setEnabled(false);ui->pushButton_6->setEnabled(false);ui->pushButton_4->setEnabled(true);}void Widget::on_pushButton_3_clicked()
{QString data=ui->textEdit->toPlainText();// socket->write(data.toStdString().data());socket->write(data.toLatin1());ui->textEdit->clear();
}void Widget::on_pushButton_2_clicked()
{//开关灯指令if(flaglight==1){ui->pushButton_2->setStyleSheet("border-image: url(:/new/prefix1/deng1.png);");socket->write("light_on");ui->pushButton_2->setText("目前\n 灯 开");flaglight=2;}else{ui->pushButton_2->setStyleSheet("border:none;");socket->write("light_off");ui->pushButton_2->setText("目前\n 灯 关");flaglight=1;}
}void Widget::on_pushButton_6_clicked()
{//开风扇指令if(flagfeng==1){ui->pushButton_6->setStyleSheet("border-image: url(:/new/prefix1/feng0.2.png);");socket->write("feng_on");ui->pushButton_6->setText("目前\n 风扇 开");flagfeng=2;}else{ui->pushButton_6->setStyleSheet("border-image: url(:/new/prefix1/feng0.1.png);");socket->write("feng_off");ui->pushButton_6->setText("目前\n 风扇 关");flagfeng=1;}}void Widget::on_pushButton_5_clicked()
{//缩放视频画面static int flag = 1;if(flag==1){//ui->textEdit_2->setGeometry(300,150,700,500);//ui->textEdit_2->setGeometry(440,240,520,322);//ui->label_4->setGeometry(450,250,500,300);ui->textEdit_2->setGeometry(this->width()/1000*440,this->height()/600*240,this->width()/1000*520,this->height()/600*322);ui->label_4->setGeometry(this->width()/1000*450,this->height()/600*250,this->width()/1000*500,this->height()/600*300);flag=2;}else{ui->textEdit_2->setGeometry(600,240,171,201);ui->label_4->setGeometry(610,250,151,181);flag=1;}}void Widget::on_pushButton_7_clicked()
{camsocket->disconnectFromHost();camsocket->close();ui->label_11->setText("摄像头已断开!");ui->pushButton_7->setEnabled(false);ui->pushButton_9->setEnabled(true);ui->label_4->clear();}void Widget::on_pushButton_8_clicked()
{//窗帘开关if(flagcurtain==1){socket->write("chuang_on");ui->label_5->setStyleSheet("border-image: url(:/di1.2.jpg);");ui->pushButton_8->setText("目前\n  窗帘 关闭");flagcurtain=2;}else{socket->write("chuang_off");ui->label_5->setStyleSheet("border-image: url(:/new/prefix1/di1.JPG);");ui->pushButton_8->setText("目前\n  窗帘 打开");flagcurtain=1;}
}void Widget::on_pushButton_10_clicked()
{//电视开关if(flagdshi==1){socket->write("dshi_on");ui->label_6->setStyleSheet("border-image: url(:/ds.png);");flagdshi=2;}else{socket->write("dshi_off");ui->label_6->setStyleSheet("border-image: url(:/ds2.png);");flagdshi=1;}
}void Widget::on_btn_speekin_pressed()
{ui->btn_speekin->setText("松开识别");Audiodevice.startRecord("D:\\crs\\qtday1\\qtxm\\yysb\\1.pcm");
}void Widget::on_btn_speekin_released()
{//停止录音Audiodevice.stopRecord();//修改按钮文件ui->btn_speekin->setText("开始识别");//开始识别QString text = m_speech.speechIdentify("D:\\crs\\qtday1\\qtxm\\yysb\\1.pcm");QString text1 = text.mid(4,text.length()-5);qDebug()<<text1;text1 = text.left(4);qDebug()<<text1;if(text != ""){ui->textEdit->setText(text);ui->btn_speekin->setText("按住说话");if(text == "开灯。"){if(1 == flaglight && flagserver == true){speak.say("好的,正在为你开灯。");ui->pushButton_2->setStyleSheet("border-image: url(:/new/prefix1/deng1.png);");socket->write("light_on");ui->pushButton_2->setText("目前\n 灯 开");flaglight=2;return;}speak.say("主人,灯已经是打开状态!");}else if(text == "关灯。"){if(2 == flaglight && flagserver == true){speak.say("好的,正在为你关灯。");ui->pushButton_2->setStyleSheet("border:none;");socket->write("light_off");ui->pushButton_2->setText("目前\n 灯 关");flaglight=1;return;}speak.say("主人,灯已经是关闭状态!");}else if(text == "打开风扇。"){if(flagfeng==1 && flagserver == true){speak.say("好的,正在为你打开风扇。");ui->pushButton_6->setStyleSheet("border-image: url(:/new/prefix1/feng0.2.png);");socket->write("feng_on");ui->pushButton_6->setText("目前\n 风扇 开");flagfeng=2;return;}speak.say("亲爱的主人啊,风扇已经是打开状态哟。");}else if(text == "关闭风扇。"){if(flagfeng == 2 && flagserver == true){speak.say("好的,正在为你关闭风扇。");ui->pushButton_6->setStyleSheet("border-image: url(:/new/prefix1/feng0.1.png);");socket->write("feng_off");ui->pushButton_6->setText("目前\n 风扇 关");flagfeng=1;return;}speak.say("非常抱歉,风扇已经是关闭状态哟。");}else if(text == "打开电视。"){if(flagdshi==1 && flagserver == true){speak.say("好的,正在为你打开电视。");socket->write("dshi_on");ui->label_6->setStyleSheet("border-image: url(:/ds.png);");flagdshi=2;return;}speak.say("稍等我看一下,电视已经是打开状态哟。");}else if(text == "关闭电视。"){if(flagdshi == 2 && flagserver == true){speak.say("好的,正在为你关闭电视。");socket->write("dshi_off");ui->label_6->setStyleSheet("border-image: url(:/ds2.png);");flagdshi=1;return;}speak.say("正在检查状态,电视已经是关闭状态哟。");}else if(text == "打开窗帘。"){if(flagcurtain==1 && flagserver == true){speak.say("好的,正在为你打开窗帘。");socket->write("chuang_on");ui->label_5->setStyleSheet("border-image: url(:/di1.2.jpg);");ui->pushButton_8->setText("目前\n  窗帘 关闭");flagcurtain=2;return;}speak.say("检查窗帘状态,窗帘已经是打开状态哟。");}else if(text == "关闭窗帘。"){if(flagcurtain == 2 && flagserver == true){speak.say("好的,正在为你关闭窗帘。");socket->write("chuang_off");ui->label_5->setStyleSheet("border-image: url(:/new/prefix1/di1.JPG);");ui->pushButton_8->setText("目前\n  窗帘 打开");flagcurtain=1;return;}speak.say("抱歉,窗帘已经是关闭状态。");}else if(text == "打开QQ。"){speak.say("正在打开QQ。");p1->start("D:/tencent/QQ/Bin/QQScLauncher.exe");}else if(text == "打开QQ音乐。"){speak.say("正在打开QQ音乐。");p2->start("D:/tencent/qqmusic/QQMusic1869.21.17.39/QQMusic.exe");}else if(text.left(4)== "查询天气"){speak.say("正在查询。");ui->lineaddr->setText(text.mid(4,text.length()-5));}}else{ui->textEdit->setText("识别失败请重新按住说话!!!");}ui->btn_speekin->setText("按住说话");
}void Widget::on_wtobtn_clicked()
{if(6 == day){day = 0;ui->weathertext->setText(wt->processing_data(day));return;}day++;ui->weathertext->setText(wt->processing_data(day));
}void Widget::on_wyesbtn_clicked()
{if(0 == day){day = 6;ui->weathertext->setText(wt->processing_data(day));return;}day--;ui->weathertext->setText(wt->processing_data(day));
}

 ui界面:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Widget</class><widget class="QWidget" name="Widget"><property name="enabled"><bool>true</bool></property><property name="geometry"><rect><x>0</x><y>0</y><width>1000</width><height>600</height></rect></property><property name="acceptDrops"><bool>false</bool></property><property name="windowTitle"><string>语音智能家居系统</string></property><property name="windowIcon"><iconset resource="11.qrc"><normaloff>:/new/prefix1/feng0.1.png</normaloff>:/new/prefix1/feng0.1.png</iconset></property><property name="layoutDirection"><enum>Qt::LeftToRight</enum></property><property name="autoFillBackground"><bool>false</bool></property><property name="styleSheet"><string notr="true"/></property><widget class="QPushButton" name="pushButton"><property name="geometry"><rect><x>80</x><y>570</y><width>71</width><height>30</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(139, 17, 161, 96), stop:1 rgba(85, 255, 255, 255));border-bottom-right-radius: 15px;color:rgb(246, 217, 255);
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);color: rgb(255, 255, 255);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>断开服务器</string></property></widget><widget class="QPushButton" name="pushButton_2"><property name="geometry"><rect><x>601</x><y>159</y><width>60</width><height>40</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="layoutDirection"><enum>Qt::LeftToRight</enum></property><property name="styleSheet"><string notr="true">QPushButton{
border:none;
border-radius: 25px;
color: rgb(255, 231, 254);
}
QPushButton:hover{
border:none;font: 25 11pt &quot;微软雅黑 Light&quot;;text-decoration: underline;}</string></property><property name="text"><string>
灯关</string></property></widget><widget class="QPushButton" name="pushButton_3"><property name="geometry"><rect><x>360</x><y>540</y><width>75</width><height>61</height></rect></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton
{
border-style:none;
background-color: rgb(185, 255, 184);
border-top-right-radius:15px;
}
QPushButton:hover{
border-style:none;
background-color: rgb(0, 255, 184);
border-top-right-radius:30px;
}
QPushButton:pressed{
border-style:none;background-color: rgb(111, 255, 246);
border-top-right-radius:30px;
}
</string></property><property name="text"><string>发送</string></property><property name="autoDefault"><bool>false</bool></property><property name="default"><bool>false</bool></property><property name="flat"><bool>true</bool></property></widget><widget class="QPushButton" name="pushButton_4"><property name="geometry"><rect><x>9</x><y>570</y><width>71</width><height>31</height></rect></property><property name="sizePolicy"><sizepolicy hsizetype="Fixed" vsizetype="Fixed"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(229, 221, 191, 255), stop:1 rgba(85, 229, 232, 107));border-bottom-left-radius: 15px;color: rgb(131, 74, 18);
}
QPushButton:hover
{border:none;border-radius:15px;
background-color: rgb(226, 119, 105);font: 14pt &quot;楷体&quot;;
}</string></property><property name="text"><string>连接服务器</string></property></widget><widget class="QTextEdit" name="textEdit"><property name="geometry"><rect><x>160</x><y>540</y><width>201</width><height>61</height></rect></property><property name="font"><font><family>华文仿宋</family><pointsize>20</pointsize><weight>50</weight><italic>false</italic><bold>false</bold></font></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.5);
font: 20pt &quot;隶书&quot;;
font: 20pt &quot;华文仿宋&quot;;
color: rgb(255, 0, 0);</string></property><property name="html"><string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'华文仿宋'; font-size:20pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string></property></widget><widget class="QWidget" name="horizontalLayoutWidget"><property name="geometry"><rect><x>0</x><y>430</y><width>211</width><height>30</height></rect></property><layout class="QHBoxLayout" name="horizontalLayout"><property name="topMargin"><number>0</number></property><property name="rightMargin"><number>6</number></property><item><widget class="QLineEdit" name="lineEdit"><property name="font"><font><family>微软雅黑 Light</family><pointsize>10</pointsize><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.11);
color: rgb(0, 255, 127);</string></property><property name="text"><string>192.168.2.45</string></property></widget></item><item><widget class="QLabel" name="label"><property name="styleSheet"><string notr="true">font: 11pt &quot;黑体&quot;;
color: rgb(0, 255, 238);</string></property><property name="text"><string>ip地址</string></property></widget></item></layout></widget><widget class="QWidget" name="horizontalLayoutWidget_3"><property name="geometry"><rect><x>0</x><y>490</y><width>211</width><height>27</height></rect></property><layout class="QHBoxLayout" name="horizontalLayout_3"><item><widget class="QLineEdit" name="lineEdit_2"><property name="font"><font><pointsize>11</pointsize><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.11);
color: rgb(0, 255, 127);</string></property><property name="text"><string>7777</string></property></widget></item><item><widget class="QLabel" name="label_2"><property name="styleSheet"><string notr="true">font: 11pt &quot;黑体&quot;;color: rgb(0, 255, 238);</string></property><property name="text"><string>服务器端口</string></property></widget></item></layout></widget><widget class="QWidget" name="horizontalLayoutWidget_4"><property name="geometry"><rect><x>0</x><y>460</y><width>211</width><height>25</height></rect></property><layout class="QHBoxLayout" name="horizontalLayout_4"><property name="topMargin"><number>0</number></property><item><widget class="QLineEdit" name="lineEdit_3"><property name="font"><font><pointsize>11</pointsize><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.11);
color: rgb(0, 255, 127);</string></property><property name="text"><string>8888</string></property></widget></item><item><widget class="QLabel" name="label_3"><property name="styleSheet"><string notr="true">font: 11pt &quot;黑体&quot;;
color: rgb(0, 255, 238);</string></property><property name="text"><string>摄像头端口</string></property></widget></item></layout></widget><widget class="QLineEdit" name="lineEdit_wd"><property name="geometry"><rect><x>0</x><y>0</y><width>31</width><height>20</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><pointsize>12</pointsize><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.11);
color: rgb(170, 85, 255);</string></property><property name="text"><string/></property><property name="readOnly"><bool>true</bool></property></widget><widget class="QLineEdit" name="lineEdit_sd"><property name="geometry"><rect><x>0</x><y>20</y><width>31</width><height>20</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><pointsize>12</pointsize><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.11);
color: rgb(170, 85, 255);</string></property><property name="text"><string/></property><property name="readOnly"><bool>true</bool></property></widget><widget class="QLineEdit" name="lineEdit_gq"><property name="geometry"><rect><x>0</x><y>40</y><width>51</width><height>20</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><pointsize>10</pointsize><weight>75</weight><italic>false</italic><bold>true</bold><underline>false</underline><strikeout>false</strikeout><kerning>true</kerning></font></property><property name="cursor"><cursorShape>UpArrowCursor</cursorShape></property><property name="layoutDirection"><enum>Qt::RightToLeft</enum></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.11);
color: rgb(170, 85, 255);</string></property><property name="text"><string/></property><property name="readOnly"><bool>true</bool></property></widget><widget class="QLabel" name="label_4"><property name="geometry"><rect><x>610</x><y>250</y><width>151</width><height>181</height></rect></property><property name="maximumSize"><size><width>16777211</width><height>16777215</height></size></property><property name="layoutDirection"><enum>Qt::LeftToRight</enum></property><property name="styleSheet"><string notr="true">background-color: rgba(170, 75, 6,0.3);
color: rgb(252, 234, 255);
border-radius: 15px;</string></property><property name="text"><string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;摄像头画面&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string></property><property name="scaledContents"><bool>true</bool></property></widget><widget class="QLabel" name="label_5"><property name="geometry"><rect><x>0</x><y>0</y><width>1001</width><height>601</height></rect></property><property name="font"><font><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>ArrowCursor</cursorShape></property><property name="layoutDirection"><enum>Qt::RightToLeft</enum></property><property name="autoFillBackground"><bool>false</bool></property><property name="styleSheet"><string notr="true">border-image: url(:/new/prefix1/di1.JPG);</string></property><property name="text"><string/></property><property name="scaledContents"><bool>true</bool></property></widget><widget class="QPushButton" name="pushButton_6"><property name="geometry"><rect><x>330</x><y>370</y><width>111</width><height>171</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><pointsize>8</pointsize><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="layoutDirection"><enum>Qt::LeftToRight</enum></property><property name="styleSheet"><string notr="true">QPushButton{
border-image: url(:/new/prefix1/feng0.1.png);
border:none;
color: rgb(255, 231, 254);
}
QPushButton:hover{
border-image: url(:/new/prefix1/feng0.2.png);
border:none;font: 25 11pt &quot;微软雅黑 Light&quot;;text-decoration: underline;}</string></property><property name="text"><string>风扇 关</string></property></widget><widget class="QLabel" name="label_7"><property name="geometry"><rect><x>32</x><y>6</y><width>54</width><height>12</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">color: rgb(170, 255, 127);
color: rgb(0, 255, 127);</string></property><property name="text"><string>℃ 温度</string></property></widget><widget class="QLabel" name="label_8"><property name="geometry"><rect><x>36</x><y>24</y><width>54</width><height>12</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">color: rgb(0, 255, 127);</string></property><property name="text"><string>%rh 湿度</string></property></widget><widget class="QLabel" name="label_9"><property name="geometry"><rect><x>53</x><y>43</y><width>54</width><height>12</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">color: rgb(0, 255, 127);</string></property><property name="text"><string>lux 亮度</string></property></widget><widget class="QLabel" name="label_10"><property name="geometry"><rect><x>5</x><y>58</y><width>101</width><height>21</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><pointsize>10</pointsize><weight>75</weight><bold>true</bold></font></property><property name="styleSheet"><string notr="true">color: rgb(189, 92, 35);</string></property><property name="text"><string>室内环境属性</string></property></widget><widget class="QTextEdit" name="textEdit_2"><property name="geometry"><rect><x>600</x><y>240</y><width>171</width><height>201</height></rect></property><property name="maximumSize"><size><width>16777215</width><height>16777215</height></size></property><property name="styleSheet"><string notr="true">border-radius: 10px;
background-color: rgba(255, 255, 255,0.5);
div{
box-shaow:20px 20px #2600ff;
}</string></property><property name="readOnly"><bool>true</bool></property></widget><widget class="QPushButton" name="pushButton_5"><property name="geometry"><rect><x>650</x><y>220</y><width>75</width><height>23</height></rect></property><property name="font"><font><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton{
border:none;
border-radius: 25px;
color: rgb(223, 204, 223);
}
QPushButton:hover{
border:none;font: 25 11pt &quot;微软雅黑 Light&quot;;text-decoration: underline;}</string></property><property name="text"><string>摄像缩放</string></property></widget><widget class="QPushButton" name="pushButton_7"><property name="geometry"><rect><x>80</x><y>540</y><width>71</width><height>30</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(130, 198, 213, 62), stop:1 rgba(109, 202, 171, 255));border-top-right-radius: 15px;color: rgb(131, 74, 18);
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>断开摄像头</string></property></widget><widget class="QLabel" name="label_11"><property name="geometry"><rect><x>0</x><y>180</y><width>111</width><height>21</height></rect></property><property name="font"><font><family>华文琥珀</family></font></property><property name="styleSheet"><string notr="true">color: rgb(254, 122, 35);</string></property><property name="text"><string>摄像头信息</string></property></widget><widget class="QLabel" name="label_12"><property name="geometry"><rect><x>0</x><y>160</y><width>111</width><height>20</height></rect></property><property name="font"><font><family>华文琥珀</family></font></property><property name="styleSheet"><string notr="true">color: rgb(174, 42, 255);
</string></property><property name="text"><string>服务器信息</string></property></widget><widget class="QPushButton" name="pushButton_8"><property name="geometry"><rect><x>150</x><y>0</y><width>75</width><height>31</height></rect></property><property name="font"><font><family>华文琥珀</family></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;	background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.489, fy:0.523, stop:0 rgba(205, 162, 255, 255), stop:1 rgba(255, 159, 187, 53));border-radius: 15px;;color: rgb(170, 0, 0);
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>窗帘 关闭</string></property></widget><widget class="QPushButton" name="pushButton_9"><property name="geometry"><rect><x>9</x><y>540</y><width>71</width><height>31</height></rect></property><property name="font"><font><family>微软雅黑 Light</family><weight>75</weight><bold>true</bold></font></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;color:rgb(246, 217, 255);background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(216, 134, 137, 161), stop:1 rgba(214, 213, 255, 125));border-top-left-radius: 15px;;
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);color: rgb(255, 255, 255);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>连接摄像头</string></property></widget><widget class="QLabel" name="label_6"><property name="geometry"><rect><x>857</x><y>224</y><width>100</width><height>211</height></rect></property><property name="font"><font><family>Arial Narrow</family><pointsize>13</pointsize></font></property><property name="styleSheet"><string notr="true">border-image: url(:/ds2.png);</string></property><property name="text"><string/></property></widget><widget class="QPushButton" name="pushButton_10"><property name="geometry"><rect><x>800</x><y>570</y><width>75</width><height>31</height></rect></property><property name="cursor"><cursorShape>PointingHandCursor</cursorShape></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;	background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.489, fy:0.523, stop:0 rgba(255, 209, 162, 255), stop:1 rgba(255, 159, 187, 53));border-radius: 15px;;color: rgb(170, 0, 0);font: 75 9pt &quot;Agency FB&quot;;
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>电视开关</string></property></widget><widget class="QWidget" name="verticalLayoutWidget"><property name="geometry"><rect><x>0</x><y>280</y><width>311</width><height>151</height></rect></property><layout class="QVBoxLayout" name="verticalLayout"><item><layout class="QHBoxLayout" name="horizontalLayout_5"><item><widget class="QPushButton" name="wyesbtn"><property name="font"><font><family>华文琥珀</family><pointsize>9</pointsize><weight>50</weight><italic>false</italic><bold>false</bold></font></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;font: 9pt &quot;华文琥珀&quot;;background-color: rgb(0, 255, 226);border-radius: 30px;color: rgb(131, 74, 18);
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>前一天</string></property></widget></item><item><widget class="QLineEdit" name="lineaddr"><property name="sizePolicy"><sizepolicy hsizetype="Preferred" vsizetype="Fixed"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="layoutDirection"><enum>Qt::LeftToRight</enum></property><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.60);
font: 75 12pt &quot;Agency FB&quot;;
color: rgb(222, 125, 93);</string></property><property name="text"><string>成都</string></property><property name="alignment"><set>Qt::AlignCenter</set></property></widget></item><item><widget class="QPushButton" name="wtobtn"><property name="styleSheet"><string notr="true">QPushButton
{border:none;font: 9pt &quot;华文琥珀&quot;;background-color: rgb(0, 255, 226);border-radius: 30px;color: rgb(131, 74, 18);
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>下一天</string></property></widget></item></layout></item><item><widget class="QTextEdit" name="weathertext"><property name="styleSheet"><string notr="true">background-color: rgba(255, 255, 255,0.60);
color: rgb(0, 153, 255);
font: 75 10pt &quot;Agency FB&quot;;</string></property><property name="html"><string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Agency FB'; font-size:10pt; font-weight:72; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string></property></widget></item></layout></widget><widget class="QPushButton" name="btn_speekin"><property name="geometry"><rect><x>570</x><y>540</y><width>60</width><height>60</height></rect></property><property name="styleSheet"><string notr="true">QPushButton
{border:none;font: 9pt &quot;华文琥珀&quot;;background-color: rgb(0, 255, 226);border-radius: 30px;color: rgb(131, 74, 18);
}
QPushButton:hover
{border:none;border-radius:15px;	background-color: rgb(226, 119, 105);font: 12pt &quot;楷体&quot;;
}</string></property><property name="text"><string>按下说话</string></property></widget><zorder>label_5</zorder><zorder>label_6</zorder><zorder>pushButton</zorder><zorder>pushButton_2</zorder><zorder>pushButton_3</zorder><zorder>pushButton_4</zorder><zorder>textEdit</zorder><zorder>horizontalLayoutWidget</zorder><zorder>horizontalLayoutWidget_3</zorder><zorder>horizontalLayoutWidget_4</zorder><zorder>lineEdit_wd</zorder><zorder>lineEdit_sd</zorder><zorder>lineEdit_gq</zorder><zorder>pushButton_6</zorder><zorder>label_7</zorder><zorder>label_8</zorder><zorder>label_9</zorder><zorder>label_10</zorder><zorder>textEdit_2</zorder><zorder>label_4</zorder><zorder>pushButton_5</zorder><zorder>pushButton_7</zorder><zorder>label_11</zorder><zorder>label_12</zorder><zorder>pushButton_8</zorder><zorder>pushButton_9</zorder><zorder>pushButton_10</zorder><zorder>verticalLayoutWidget</zorder><zorder>btn_speekin</zorder></widget><layoutdefault spacing="6" margin="11"/><resources><include location="11.qrc"/></resources><connections/>
</ui>

 演示:

语音控制系统

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/23968.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python调用百度API进行语音识别

目录 1.作者介绍2.基于百度API的普通话识别2.1语音识别2.2百度API调用方法 3&#xff0e;实验3.1实验准备3.2实验结果 4.实验代码 1.作者介绍 高志翔&#xff0c;男&#xff0c;西安工程大学电子信息学院&#xff0c;2021级研究生 研究方向&#xff1a;机器视觉与人工智能 电…

百度语音识别API的简单应用

1. prepare 根据百度开发文档的提示可以知道&#xff0c;API仅能处理特定格式的语音文件。 由于底层识别使用的是pcm&#xff0c;因此推荐直接上传pcm文件。如果上传其它格式&#xff0c;会在服务器端转码成pcm&#xff0c;调用接口的耗时会增加。 语音识别仅支持以下格式 &am…

什么是CatGPT-使用效果如何-

个人使用效果&#xff0c;评分优&#xff0c;足以满足教学和填表。 程序媛借助CatGPT&#xff08;ChatGPT更佳&#xff09;&#xff0c;基本上可以秒杀不用此类工具的程序猿&#xff08;男&#xff09;&#xff01;&#xff01;&#xff01; 问&#xff1a;为什么使用AIGC能大幅…

OpenAI ChatGPT3.5 completion API 入门指南

官方介绍 ChatGPT 由 OpenAI 最先进的语言模型 gpt-3.5-turbo 提供支持。 使用 OpenAI API&#xff0c;您可以使用 GPT-3.5-turbo 构建自己的程序来做一些如下的事情&#xff1a; 起草电子邮件或其他书面文件编写 Python 代码回答关于一组文档的问题创建对话代理程序为你的软件…

英语二-电子邮件邀请短文写作

1. 邮件模板 Dear 邀请人, Hope you have a great day. I am writing this email to invite you to attend 主题. Please kindly find the following information for your reference: Time: 时间 Address: 地点 We hope that nothing will prevent you from coming, as…

怎样收智商税

智商税的历史源远流长&#xff0c;史上最著名的案例&#xff0c;是 1313 年起天主教会开始发售的“赎罪券”&#xff1a;教皇宣称教徒购买此券&#xff0c;可以赦免罪罚&#xff0c;其宣传是“金币投进柜子当啷一响时&#xff0c;灵魂就可以升天堂了”。此案例诠释了智商税的几…

AIGC周报|让AI来画《海贼王》;苹果限制员工使用ChatGPT;李彦宏:不担心大模型会让工作消失

AIGC&#xff08;AI Generated Content&#xff09;即人工智能生成内容。近期爆火的 AI 聊天机器人 ChatGPT&#xff0c;以及 DallE 2、Stable Diffusion 等文生图模型&#xff0c;都属于 AIGC 的典型案例&#xff0c;它们通过借鉴现有的、人类创造的内容来快速完成内容创作。 …

谷歌正式开放智能 AI 机器人 Bard 迎战 ChatGPT,附申请教程

随着 ChatGPT 掀起了 AI 时代的浪潮之后&#xff0c;微软必应 Bing Chat 机器人、Office 以及百度的“文心一言”等都已经离开实验室&#xff0c;正式在公众的赛道上比拼了。3月21日周二&#xff0c;美国科技巨头谷歌公司推出了 AI 聊天机器人 Bard 的测试版本&#xff0c;以期…

吴恩达 ChatGPT Prompt Engineering for Developers 系列课程笔记--01 Introduction

01课程介绍Introduction 1) 两种LLM(Large Language Models) Base LLM&#xff1a;根据训练数据自动预测下一个单词。例如&#xff1a;给定"Once upon a time, there was a unicorn"&#xff0c;LLM会自动生成下面的文章"that lived in a magical forrest with…

计算机考研复试面试系列 计算机专业英语篇

计算机考研复试面试系列 计算机专业英语篇 在复习过程中&#xff0c;我用心查阅并整理了在考研复试面试中可能问到的大部分问题&#xff0c;并分点整理了答案&#xff0c;可以直接理解背诵并加上自己的语言润色!极力推荐打印下来看&#xff0c;效率更高&#xff01; 此系列一共…

AI时代的三类人:探索掌握AIGC,引领未来的人才之路

&#xff08;本文阅读时间&#xff1a;6 分钟&#xff09; 1 AI时代&#xff1a;ChatGPT引领AIGC技术革命 对于那些热衷于探索新技术的小伙伴而言&#xff0c;ChatGPT早已超越了抽象的概念&#xff0c;我们对其能力已有所了解。那么&#xff0c;ChatGPT究竟能够做些什么呢&…

AGI 大模型创业时代的创业公司新形态:11 人的 Midjourney 不是偶然 | 同为开发绘画AI的团队,Midjourney是怎么取得今天的成就的呢?

同为开发绘画AI的团队,Midjourney是怎么取得今天的成就的呢? 目录 同为开发绘画AI的团队,Midjourney是怎么取得今天的成就的呢?</

Web开发课程实验(二):Servlet+DAO实现数据库基本交互

实验内容&#xff1a; 使用servletDAO实现基本数据库交互 具体要求 编写一个静态网页&#xff0c;网页命名&#xff1a;student.html 编写一个Servlet&#xff0c;命名&#xff1a;StudentServlet 创建hit数据库&#xff08;PostgreSQL或MySQL均可&#xff09;&#xff0c;其…

占有统治地位的Transformer究竟是什么

讲个有趣的小故事 我高二那年从乙班考入了甲班&#xff0c;对于那时的我 偏科英语最高只有108班级平均英语成绩125暴躁难为人女英语老师&#xff0c;使我上英语课时战战兢兢。英语老师很时尚&#xff0c;喜欢搞花里胡哨的词语让我们放松&#xff0c;也很尊重我虽然暴躁但维护着…

8 Surprising Things You Can Do With ChatGPT 你可以用 ChatGPT 做的 8 件令人惊讶的事情

If you’ve heard about ChatGPT and think it’s just a fancy chatbot, you might be underestimating the range of what it can do. Here are some surprising things you can do with ChatGPT, whether you want to write a resume or have it dungeon-master an epic rol…

千万别错过!C/C++实现经典围棋大战,秒杀挫败柯洁的AlphaGo

在现实生活中想下围棋就必须要有棋子和棋盘&#xff0c;但是棋子好携带&#xff0c;但棋盘携带的话就和不方便了&#xff0c;所以很多人突然有雅兴想下围棋但奈何没有棋盘&#xff0c;但是随着围棋软件的出现就很好的解决了这个问题了&#xff0c;它可以让你随时随地都能过把手…

又一次输了人机大战,柯洁反复说着这两个词......

一场27日在福州与“星阵”的对决让柯洁的名字再度与“人机大战”联系在一起&#xff0c;而尽管中盘告负的结果让他“深感无力”&#xff0c;但柯洁表示未来与人工智能的对阵仍是不可避免&#xff0c;他也希望尽早出台相应的规则&#xff0c;防止未来可能利用人工智能作弊的现象…

柯洁直播中为何大笑不止 围棋人胜AI重现曙光?

新浪体育2023/05/02 柯洁直播中开心不已 4月30日&#xff0c;柯洁在b站的直播中分享了人类棋手“偷袭”击败AI的棋谱&#xff0c;坦言如果在人机大战的时候知道这个bug的话&#xff0c;或许有赢的可能。 2016&#xff0c;2017两次人机大战后&#xff0c;人与人工智能在围棋上的…

柯洁食言:明年四月,再战AI

李根 发自 凹非寺 量子位 报道 | 公众号 QbitAI “我说不再跟AI下棋&#xff0c;现在食言了。” 刚刚&#xff0c;人类围棋第一人柯洁九段宣布&#xff1a;明年4月&#xff0c;将再次与围棋AI交锋。 对话柯洁&#xff1a;我喜欢自我挑战 今年4月的乌镇&#xff0c;与AlphaGo的第…

今天,给柯洁老师打电话

问耕 发自 凹非寺量子位 出品 | 公众号 QbitAI △ 配图来自柯洁微博 如果你看到这一篇推送&#xff0c;即使没有号码&#xff0c;也希望你给柯洁老师打电话。 可以热烈一点~ 因为&#xff0c;他成功复仇了&#xff01; 柯洁战胜了不久前刚刚碾压了他的腾讯围棋AI绝艺&#xff0…