基于Matlab编写的语音端点检测(5)

2018-11-17 20:20

% Choose default command line output for duandianjiance handles.output = hObject;

% Update handles structure guidata(hObject, handles);

% UIWAIT makes duandianjiance wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = duandianjiance_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 prebutton.

function prebutton_Callback(hObject, eventdata, handles) % hObject handle to prebutton (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) signal=handles.wavsignal;

signal=filter([1,-0.9375],1,signal);%预加重滤波 axes(handles.wavaxes)

plot(signal)%显示预加重后波形 title('预加重滤波后语音波形'); handles.wavsignal=signal; framelength=256;%窗长;

framenumber=fix(length(signal)/framelength); for i=1:framenumber;

framesignal(i,1:framelength)=signal((i-1)*framelength+1:i*framelength);

end

handles.framesignal=framesignal; %Update handles structure guidata(hObject,handles);

% --- Executes on button press in openbutton.

function openbutton_Callback(hObject, eventdata, handles) % hObject handle to openbutton (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

%当打开新的语音文件后,将3个轴对象清空,将各个门限值设置为零 clc;

axes(handles.wavaxes);cla reset;box on;set(gca,'XTickLabel',[],'YTickLabel',[]);

axes(handles.Energeaxe);cla reset;box on;set(gca,'XTickLabel',[],'YTickLabel',[]);

axes(handles.Zerorateaxes);cla reset;box on;set(gca,'XTickLabel',[],'YTickLabel',[]);

set(handles.T1edit,'string',0); set(handles.T2edit,'string',0); set(handles.T3edit,'string',0); %打开待处理的语音文件

[filename,pathname]=uigetfile({'*.wav','All Wav Files'},'选择语音文件'); if filename == 0

return;%如果没有选择新的文件,则返回 end

file=fullfile(pathname,filename);%文件名

[signal,fs,bit]=wavread(file);%读取选择的语音数据 axes(handles.wavaxes) plot(signal)%显示波形 handles.wavsignal=signal; %update handles structure guidata(hObject,handles);

% --- Executes on button press in Energebutton.

function Energebutton_Callback(hObject, eventdata, handles) % hObject handle to Energebutton (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) framesignal=handles.framesignal;

framenumber=size(framesignal,1);%获得数据桢数 for i=1:framenumber; E(i)=0;

E(i)=sum(framesignal(i,:).^2);%计算短时能量 end

axes(handles.Energeaxes)

%c=[1 2 3 4 5 6 4 3 3 3 3];

plot(E);%将能量只显示在能量窗口 handles.E=E;

%Update handles structure guidata(hObject,handles);

% --- Executes on button press in Zeroratebotton.

function Zeroratebotton_Callback(hObject, eventdata, handles) % hObject handle to Zeroratebotton (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) framesignal=handles.framesignal;

framenumber=size(framesignal,1);%语音数据帧数 framelength=size(framesignal,2);%获取语音帧长 for i=1:framenumber; Z(i)=0;

for j=2:framelength-1;

Z(i)=Z(i)+abs(sign(framesignal(i,j))-sign(framesignal(i,j-1))); end end

axes(handles.Zerorateaxes) plot(Z)

handles.Z=Z;

%Update handles structure guidata(hObject,handles);

% --- Executes on button press in Detectpointbutton.

function Detectpointbutton_Callback(hObject, eventdata, handles) % hObject handle to Detectpointbutton (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB %handles structure with handles and user data (see GUIDATA)

function T1edit_Callback(hObject, eventdata, handles) % hObject handle to T1edit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of T1edit as text

% str2double(get(hObject,'String')) returns contents of T1edit as a double

% --- Executes during object creation, after setting all properties. function T1edit_CreateFcn(hObject, eventdata, handles) % hObject handle to T1edit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function T2edit_Callback(hObject, eventdata, handles) % hObject handle to T2edit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clc

axes(handles.Energeaxes);cla reset;box on;

set(gca,'XTicklabel',[],'YTicklabel',[]);%在输入新的a,b值时,要清空Energeaxes里的图像

a=get(handles.T1edit,'string');%获得α值 b=get(handles.T2edit,'string');%获得β值 a=str2num(a); b=str2num(b); E=handles.E;

MeanE=mean(E(1:10));%求前10帧的能量均值 MINE=min(E);%计算能量最小值 MAXE=max(E);%计算能量的最大值

%计算TL(低能量阈值)和TH(高能量阈值)

I1=a*(MAXE-MINE)+MINE;%I1=α×(MAXE-MINE)+MINE; I2=b*MINE;%I2=β×MINE; TL=min(I1,I2); TH=5*TL;

axes(handles.Energeaxes) plot(E) hold on

Line([1 length(E)],[TL TL]','Color','b');%用红线画出TL值 hold on

line([1 length(E)],[TH,TH]','Color','g');%用蓝线画出TH值 handles.TL=TL;

handles.TH=TH;

%Update handles structure guidata(hObject,handles);

% Hints: get(hObject,'String') returns contents of T2edit as text

% str2double(get(hObject,'String')) returns contents of T2edit as a double

% --- Executes during object creation, after setting all properties. function T2edit_CreateFcn(hObject, eventdata, handles) % hObject handle to T2edit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function T3edit_Callback(hObject, eventdata, handles) % hObject handle to T3edit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clc

axes(handles.Zeroratateaxes);cla reset;box on; set(gca,'XTickLabel',[],'YtickLabel',[]); v=get(handles.T3edit,'string'); v=str2num(v); Z=handles.Z;

MeanZ=mean(Z(1:10)); VarZ=std(Z(1:10));

ZT=min(v,MeanZ+VarZ); axes(handles.Zerorateaxes) plot(Z) hold on

Line([1,length(Z)],[ZT,ZT]','Color','b'); handles.ZT=ZT;

%Update handles structure guidata(hObject,handles);

% Hints: get(hObject,'String') returns contents of T3edit as text

% str2double(get(hObject,'String')) returns contents of T3edit as a double

% --- Executes during object creation, after setting all properties. function T3edit_CreateFcn(hObject, eventdata, handles) % hObject handle to T3edit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end


基于Matlab编写的语音端点检测(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:保温

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: