function varargout = untitled(varargin)/n% UNTITLED MATLAB code for untitled.fig/n% UNTITLED, by itself, creates a new UNTITLED or raises the existing/n% singleton*./n%/n% H = UNTITLED returns the handle to a new UNTITLED or the handle to/n% the existing singleton*./n%/n% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local/n% function named CALLBACK in UNTITLED.M with the given input arguments./n%/n% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the/n% existing singleton*. Starting from the left, property value pairs are/n% applied to the GUI before untitled_OpeningFcn gets called. An/n% unrecognized property name or invalid value makes property application/n% stop. All inputs are passed to untitled_OpeningFcn via varargin./n%/n% See GUI Options on GUIDE's Tools menu. Choose /'GUI allows only one/n% instance to run (singleton)/'./n%/n% See also: GUIDE, GUIDATA, GUIHANDLES/n/n% Edit the above text to modify the response to help untitled/n/n% Last Modified by GUIDE v2.5 10-Mar-2023 20:37:30/n/n% Begin initialization code - DO NOT EDIT/ngui_Singleton = 1;/ngui_State = struct('gui_Name', mfilename, .../n 'gui_Singleton', gui_Singleton, .../n 'gui_OpeningFcn', @untitled_OpeningFcn, .../n 'gui_OutputFcn', @untitled_OutputFcn, .../n 'gui_LayoutFcn', [] , .../n 'gui_Callback', []);/nif nargin && ischar(varargin{1})/n gui_State.gui_Callback = str2func(varargin{1});/nend/n/nif nargout/n [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});/nelse/n gui_mainfcn(gui_State, varargin{:});/nend/n% End initialization code - DO NOT EDIT/n/n/n% --- Executes just before untitled is made visible./nfunction untitled_OpeningFcn(hObject, eventdata, handles, varargin)/n% This function has no output args, see OutputFcn./n% hObject handle to figure/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/n% varargin command line arguments to untitled (see VARARGIN)/n/n% Choose default command line output for untitled/nhandles.output = hObject;/n/n% Update handles structure/nguidata(hObject, handles);/n/n% UIWAIT makes untitled wait for user response (see UIRESUME)/n% uiwait(handles.figure1);/n/n/n% --- Outputs from this function are returned to the command line./nfunction varargout = untitled_OutputFcn(hObject, eventdata, handles) /n% varargout cell array for returning output args (see VARARGOUT);/n% hObject handle to figure/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/n/n% Get default command line output from handles structure/nvarargout{1} = handles.output;/n/n/n% --- Executes on button press in pushbutton1./nfunction pushbutton1_Callback(hObject, eventdata, handles)/n% hObject handle to pushbutton1 (see GCBO)/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/nrecObj=audiorecorder;/ndisp('Start recording.');/nrecordblocking(recObj,5);%从麦克风录取20s音频/ndisp('End of recording.');/nplay(recObj);/ny=getaudiodata(recObj);/nfilename='D://graduation design//Recorded audio//recording.wav';/naudiowrite(filename,y,12000);/n[Y,FS]=audioread(filename);/nplayer=audioplayer(Y,FS);/ninfo=audioinfo(filename);/n/n/n% --- Executes on button press in pushbutton2./nfunction pushbutton2_Callback(hObject, eventdata, handles)/n% hObject handle to pushbutton2 (see GCBO)/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/nglobal x; %文件/nglobal Fs; %采样频率/nglobal tl; /nglobal x2;/n[filename, pathname] = uigetfile('.wav', '选择音频文件');/nif isequal(filename,0)/n disp('User selected Cancel')/nelse/n path = fullfile(pathname, filename);/n [handles.x,handles.Fs]=audioread(path);/n x=handles.x;/n Fs=handles.Fs;/n axes(handles.axes1);/n tl=[0:1/Fs:(length(handles.x)-1)/Fs]; %时间尺度/n plot(tl,handles.x);/n title('语音时域波形');/n xlabel('时间/s');/n grid on;/n %player=audioplayer(x,Fs);/n /n N=length(handles.x);/n df=Fs/N;/n w=[0:df:df*(N-1)] - Fs/2; %频率尺度/n X=fft(handles.x);/n X=fftshift(X);/n %axes(handles.axes2);/n %plot(w,abs(X)/max(abs(X)));/n %axis([-10000,10000,0,1]);/n %title('语音频谱');/n %xlabel('频率/Hz');/n %grid on;/n %x2=x;/n /n %二、小波降噪wden函数 具体参数选取 原理+结合人耳试听/n%wname = 'coif5';'db2';'sym4'/n [Y,FS]=audioread(path); %将声音放到matlab中/n info=audioinfo(path); %得到声音的格式、数位、频率等/n T=1/FS; %采样时间/n t=(0:length(Y)-1)*T;%时间/n yz=Y(:,1);%左声道/n lev=15;/n/n xdDWT= wden(yz,'heursure','h','mln',lev,'db3');/n player=audioplayer(xdDWT,Fs);/n%[dnsig4s,c4,l4,threshold_heursure] = wden(yz,'heursure','h','mln',lev,wname);/n axes(handles.axes2);/n plot(t,xdDWT);/n title('降噪后波形');/n /nend/n/n/n% --- Executes on button press in pushbutton3./nfunction pushbutton3_Callback(hObject, eventdata, handles)/n% hObject handle to pushbutton3 (see GCBO)/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/nglobal player;/nglobal xdDWT;/nglobal Fs;/nplayer=audioplayer(xdDWT,Fs);/n%sound(x,Fs);/nplay(player);/n%play(x,Fs);/n/n/n% --- Executes on button press in pushbutton4./nfunction pushbutton4_Callback(hObject, eventdata, handles)/n% hObject handle to pushbutton4 (see GCBO)/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/nglobal player;/nglobal x;/nglobal Fs;/n/npause(player);/n/n/n/n% --- Executes on button press in pushbutton5./nfunction pushbutton5_Callback(hObject, eventdata, handles)/n% hObject handle to pushbutton5 (see GCBO)/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/nglobal player;/nglobal x;/nglobal Fs;/n/nstop(player);/n%clear sound;/n/n/n% --- Executes on button press in pushbutton6./nfunction pushbutton6_Callback(hObject, eventdata, handles)/n% hObject handle to pushbutton6 (see GCBO)/n% eventdata reserved - to be defined in a future version of MATLAB/n% handles structure with handles and user data (see GUIDATA)/nglobal player;/nglobal x;/nglobal Fs;/n/nresume(player);/

MATLAB 语音降噪 GUI - 使用小波变换去除噪声

原文地址: https://www.cveoy.top/t/topic/nG6t 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录