function varargout = untitled1(varargin)
%UNTITLED1 MATLAB code file for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 using the
% given property value pairs. Unrecognized properties are passed via
% varargin to untitled1_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% UNTITLED1('CALLBACK') and UNTITLED1('CALLBACK',hObject,...) call the
% local function named CALLBACK in UNTITLED1.M with the given input
% arguments.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled1
% Last Modified by GUIDE v2.5 03-Nov-2021 20:18:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled1 is made visible.
function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for untitled1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled1 wait for user response (see UIRESUME)
% uiwait(handles.figure1)
% --- Outputs from this function are returned to the command line.
function varargout = untitled1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all;
clear all;
clc %起始清空
global music;
global MyRecording;
[x3,f5]=audioread('start1.mp3');%读取录音
sound(x3,f5);
music=audiorecorder(20000,16,2); %创建保存音频的对象
recordblocking (music,3); %录制3s音频
MyRecording=getaudiodata(music); %得到以n*2列数字矩阵存储的刚录制的音频信号
audiowrite('myspeech.wav' , MyRecording , 20000);
global hmm
global x
global fs
load hmm.mat
[x, fs]=audioread('myspeech.wav');
[x1,x2]=vad(x,fs);
O=mfcc(x);
O=O(x1:x2-5,:);
for j=1:10
pout(j)=viterbi(hmm{j},O);
end
[~,n]=max(pout);
%delete(d);
c=num2str(n-1);
if(c=='0')
string=sprintf('识别结果:你好');
msgbox(string,'识别结果','none');
elseif(c=='1')
string=sprintf('识别结果:小布小布');
msgbox(string,'识别结果','none');
elseif(c=='2')
string=sprintf('识别结果:食堂');
msgbox(string,'识别结果','none');
elseif(c=='3')
string=sprintf('识别结果:位置');
msgbox(string,'识别结果','none');
elseif(c=='4')
string=sprintf('识别结果:吃饭');
msgbox(string,'识别结果','none');
elseif(c=='5')
string=sprintf('识别结果:背诗');
msgbox(string,'识别结果','none');
elseif(c=='6')
string=sprintf('识别结果:喝水');
msgbox(string,'识别结果','none');
elseif(c=='7')
string=sprintf('识别结果:天气好吗');
msgbox(string,'识别结果','none');
elseif(c=='8')
string=sprintf('识别结果:睡觉');
msgbox(string,'识别结果','none');
elseif(c=='9')
string=sprintf('识别结果:成绩');
msgbox(string,'识别结果','none');
end
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, ~, ~)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all;
clear all;
clc %起始清空
global music;
global MyRecording;
[x3,f5]=audioread('start.mp3');%读取录音
sound(x3,f5);
music=audiorecorder(20000,16,2); %创建保存音频的对象
recordblocking (music,3); %录制3s音频
MyRecording=getaudiodata(music); %得到以n*2列数字矩阵存储的刚录制的音频信号
audiowrite('myspeech.wav' , MyRecording , 20000);%将音频存入
global hmm
global x
global fs
load hmm.mat %引入hmm 模型训练出的矩阵
[x,fs]=audioread('myspeech.wav');%读取录音
[x1,x2]=vad(x,fs);
O=mfcc(x);
O=O(x1:x2-5,:);
for j=1:10
pout(j)=viterbi(hmm{j},O);
end
[~,n]=max(pout);
c=num2str(n-1);
b=round(rand(1,1)*2);
disp(b);
if(c=='0')
if(b==1)
[x,fs]=audioread('hello1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('hello2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('hello3.mp3');
sound(x,fs);
end
elseif(c=='1')
if(b==1)
[x,fs]=audioread('en1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('en2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('en3.mp3');
sound(x,fs);
end
elseif(c=='2')
if(b==1)
[x,fs]=audioread('shitang1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('shitang2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('shitang3.mp3');
sound(x,fs);
end
elseif(c=='3')
if(b==1)
[x,fs]=audioread('weizhi1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('weizhi2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('weizhi3.mp3');
sound(x,fs);
end
elseif(c=='4')
if(b==1)
[x,fs]=audioread('chifan1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('chifan2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('chifan3.mp3');
sound(x,fs);
end
elseif(c=='5')
if(b==1)
[x,fs]=audioread('beishi1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('beishi2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('beishi3.mp3');
sound(x,fs);
end
elseif(c=='7')
if(b==1)
[x,fs]=audioread('tianqi1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('tianqi2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('tianqi3.mp3');
sound(x,fs);
end
elseif(c=='8')
if(b==1)
[x,fs]=audioread('shuijiao1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('shuijiao2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('shuijiao3.mp3');
sound(x,fs);
end
elseif(c=='9')
if(b==1)
[x,fs]=audioread('chengji1.mp3');
sound(x,fs);
elseif(b==2)
[x,fs]=audioread('chengji2.mp3');
sound(x,fs);
elseif(b==0)
[x,fs]=audioread('chengji3.mp3');
sound(x,fs);
end
else
[x,fs]=audioread('other.mp3');
sound(x,fs);
end
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with
Matlab科研辅导帮
- 粉丝: 3w+
- 资源: 7810
最新资源
- 毕设和企业适用springboot社交应用平台类及金融数据分析平台源码+论文+视频.zip
- 毕设和企业适用springboot社交应用平台类及交通信息平台源码+论文+视频.zip
- 毕设和企业适用springboot人力资源管理类及用户数据分析平台源码+论文+视频.zip
- 毕设和企业适用springboot人力资源管理类及用户体验优化平台源码+论文+视频.zip
- 毕设和企业适用springboot人力资源管理类及用户行为分析平台源码+论文+视频.zip
- 毕设和企业适用springboot人力资源管理类及运动管理平台源码+论文+视频.zip
- 毕设和企业适用springboot人力资源管理类及智能化系统源码+论文+视频.zip
- 毕设和企业适用springboot社交互动平台类及社交媒体平台源码+论文+视频.zip
- 毕设和企业适用springboot社交互动平台类及人工智能客服平台源码+论文+视频.zip
- 毕设和企业适用springboot社交互动平台类及社交游戏平台源码+论文+视频.zip
- 毕设和企业适用springboot社交应用平台类及跨平台销售系统源码+论文+视频.zip
- 毕设和企业适用springboot社交应用平台类及民生服务平台源码+论文+视频.zip
- 毕设和企业适用springboot社交互动平台类及生活服务平台源码+论文+视频.zip
- 毕设和企业适用springboot社交互动平台类及食品配送管理平台源码+论文+视频.zip
- 毕设和企业适用springboot社交互动平台类及社区服务平台源码+论文+视频.zip
- 毕设和企业适用springboot社交应用平台类及无人驾驶系统源码+论文+视频.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈