一、设计功能
- 录制音频,保存音频
- 对录制的语音信号进行频谱分析,确定该段语音的主要频率范围;
- 利用采样定理,对该段语音信号进行采样,观察不用采样频率(过采样、欠采样、临界采样)对信号的影响;
- 实现语音信号的快放、慢放、倒放、男女变声;
- 对语音信号加噪,然后进行滤波,分析不同的滤波方式对信号的影响;
- 实现两音频的合成、拼接;
- 利用MATLAB GUI制作语音信号采集与分析演示系统;
二、设计步骤
1.创建GUI界面
2.新建空白界面
3.拖放控件,双击控件修改tag值和string
4.最后界面布置为图示,右键点击任何一个控件,进入回调函数callback。
5.在OpeningFcn中写入下面程序
% --- Executes just before functionalDSP is made visible. function functionalDSP_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 command line arguments to functionalDSP (see VARARGIN) % Choose default command line output for functionalDSP handles.output = hObject; % Update handles structure guidata(hObject, handles); h1=gcf; set(h1,'Name','多功能语音处理器','Resize','on'); h2=uimenu(h1,'label','功能'); h3=uimenu(h2,'label','基本功能'); h4=uimenu(h2,'label','采样定理'); h5=uimenu(h2,'label','快慢放'); h6=uimenu(h2,'label','加噪去噪'); h7=uimenu(h2,'label','滤波器设计'); h8=uimenu(h2,'label','合成拼接'); h12=uimenu(h1,'label','设计人员'); h13=uimenu(h12,'label','孙宁宁'); h14=uimenu(h12,'label','宝历'); h15=uimenu(h12,'label','李佳桐'); h16=uimenu(h12,'label','马宁泽'); h17=uimenu(h12,'label','王璐'); h18=uimenu(h12,'label','王智聪'); % UIWAIT makes functionalDSP wait for user response (see UIRESUME) % uiwait(handles.h1);
6.编辑“录制1”功能
--- Executes on button press in record2.
function record2_Callback(hObject, eventdata, handles)
% hObject handle to record2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
r=audiorecorder(10000,16,1);
recordblocking(r, 3);
g=getaudiodata(r);
m='C:\Users\孙宁宁\Desktop\孙宁宁程序\x1.wav';
audiowrite(m,g,10000);%将音频写入文件
7.编辑“录制2”功能
--- Executes on button press in record2. function record2_Callback(hObject, eventdata, handles) % hObject handle to record2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) r=audiorecorder(10000,16,1); recordblocking(r, 3); g=getaudiodata(r); m='C:\Users\孙宁宁\Desktop\孙宁宁程序\x2.wav'; audiowrite(m,g,10000);%将音频写入文件
8.编辑“读取”功能
%读取信号
function read_Callback(hObject, eventdata, handles)
% hObject handle to read (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname]=uigetfile({'.'},'读取音频文件');
%文件打开对话框,返回文件名和文件路径,当文件存在时会成功返回,如果不存在,则返回不存在。
if isequal([filename pathname],[0,0])%用户取消对话框返回0
return;
end
str=[pathname filename];%将文件名和路径名组合为一个字符串,赋值给str。
[x1,Fs]=audioread(str);%读取声音信号,采样值放在向量x1中,fs为采样频率
x=x1(:,1); %对双声道信号取单声道,如果是x=x1(1:5000,1),则表示取了5000点。
handles.y1=x;%将原先采样的序列向量x给句柄y1
handles.Fs=Fs;%采样频率句柄
guidata(hObject,handles);%储存handles
9.编辑“分析”功能
% --- Executes on button press in original.