qq_27473305 2015-04-17 00:52 采纳率: 0%
浏览 1277

matlab gui语音信号处理降噪处理的按钮设置

怎么设置按钮实现调用算法功能,就是能够对语音信号进行降噪处理的功能

  • 写回答

1条回答

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-10-27 15:58
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:
    • 给你找了一篇非常好的博客,你可以看看是否有帮助,链接:matlab GUI 删除表格数据报错问题以及按钮背景图片加载问题
    • 除此之外, 这篇博客: 【语音识别】基于matlab GUI语音识别信号灯图像模拟控制(带面板)【含Matlab源码 757期】中的 二、部分源代码 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:
      function varargout = EmotionRec(varargin)
      % EMOTIONREC M-file for EmotionRec.fig
      %      EMOTIONREC, by itself, creates a new EMOTIONREC or raises the existing
      %      singleton*.
      %
      %      H = EMOTIONREC returns the handle to a new EMOTIONREC or the handle to
      %      the existing singleton*.
      %
      %      EMOTIONREC('CALLBACK',hObject,eventData,handles,...) calls the local
      %      function named CALLBACK in EMOTIONREC.M with the given input arguments.
      %
      %      EMOTIONREC('Property','Value',...) creates a new EMOTIONREC or raises the
      %      existing singleton*.  Starting from the left, property value pairs are
      %      applied to the GUI before EmotionRec_OpeningFcn gets called.  An
      %      unrecognized property name or invalid value makes property application
      %      stop.  All inputs are passed to EmotionRec_OpeningFcn via varargin.
      %
      %      *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 EmotionRec
      
      % Last Modified by GUIDE v2.5 12-May-2013 18:24:47
      
      % Begin initialization code - DO NOT EDIT
      gui_Singleton = 1;
      gui_State = struct('gui_Name',       mfilename, ...
          'gui_Singleton',  gui_Singleton, ...
          'gui_OpeningFcn', @EmotionRec_OpeningFcn, ...
          'gui_OutputFcn',  @EmotionRec_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 EmotionRec is made visible.
      function EmotionRec_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 EmotionRec (see VARARGIN)
      
      % Choose default command line output for EmotionRec
      handles.output = hObject;
      addpath(fullfile(pwd, 'voicebox'));
      clc;
      axes(handles.axes1); cla reset; box on;
      set(gca, 'XTick', [], 'YTick', [], ...
          'XTickLabel', '', 'YTickLabel', '', 'Color', [0.7020 0.7804 1.0000]);
      set(handles.axes2, 'XTick', [], 'YTick', [], ...
          'XTickLabel', '', 'YTickLabel', '', 'Color', [0.7020 0.7804 1.0000], ...
          'Box', 'On');
      handles.dirName = 0;
      handles.S = 0;
      handles.fileurl = 0;
      
      % Update handles structure
      guidata(hObject, handles);
      
      % UIWAIT makes EmotionRec wait for user response (see UIRESUME)
      % uiwait(handles.figure1);
      
      
      % --- Outputs from this function are returned to the command line.
      function varargout = EmotionRec_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)
      %% 载入语音库
      % 数据库路径
      dirName = './wav/Database';
      dirName = uigetdir(dirName);
      if isequal(dirName, 0)
          return;
      end
      msgbox(sprintf('载入%s成功!', dirName), '提示信息');
      handles.dirName = dirName;
      guidata(hObject, handles);
      
      % --- Executes on button press in pushbutton2.
      function pushbutton2_Callback(hObject, eventdata, handles)
      % hObject    handle to pushbutton2 (see GCBO)
      % eventdata  reserved - to be defined in a future version of MATLAB
      % handles    structure with handles and user data (see GUIDATA)
      %% 提取特征参数
      if isequal(handles.dirName, 0)
          msgbox('请选择音频库目录', '提示信息', 'modal');
          return;
      end
      S = GetDatabase(handles.dirName);
      handles.S = S;
      guidata(hObject, handles);
      msgbox('音频信号特征提取完毕', '提示信息', 'modal');
      
      % --- Executes on button press in pushbutton3.
      function pushbutton3_Callback(hObject, eventdata, handles)
      % hObject    handle to pushbutton3 (see GCBO)
      % eventdata  reserved - to be defined in a future version of MATLAB
      % handles    structure with handles and user data (see GUIDATA)
      %% 选择测试文件
      file = './wav/Test/1.wav';
      [Filename, Pathname] = uigetfile('*.wav', '打开新的语音文件',...
          file);
      if Filename == 0
          return;
      end
      fileurl = fullfile(Pathname,Filename);
      [signal, fs] = audioread(fileurl);
      axes(handles.axes1); cla reset; box on;
      plot(signal); title('待识别语音信号', 'FontWeight', 'Bold');
      msgbox('载入语音文件成功', '提示信息', 'modal');
      handles.fileurl = fileurl;
      handles.signal = signal;
      handles.fs = fs;
      guidata(hObject, handles);
      
      % --- Executes on button press in pushbutton4.
      function pushbutton4_Callback(hObject, eventdata, handles)
      % hObject    handle to pushbutton4 (see GCBO)
      % eventdata  reserved - to be defined in a future version of MATLAB
      % handles    structure with handles and user data (see GUIDATA)
      
      %% 识别
      if isequal(handles.fileurl, 0)
          msgbox('请选择音频文件', '提示信息', 'modal');
          return;
      end
      if isequal(handles.S, 0)
          msgbox('请计算音频库MFCC特征', '提示信息', 'modal');
          return;
      end
      S = handles.S;
      [num, MC] = Reco(S, handles.fileurl);
      result = S(num).name;
      result = result(1:2);
      c = 'r';
      function MC = GetFeather(file, flag)
      if nargin < 2
          flag = 0;
      end
      if nargin < 1
          file = '.\wav\Database\关闭\关闭_bsm.wav';
      end
      [signal, fs] = audioread(file);
      framelength = 1024;
      framenumber = fix(length(signal)/framelength);
      for L = 1:framenumber
          for m = 1:framelength
              framedata(m) = signal((L-1)*framelength+m);
          end
          E(L) = sum(framedata.^2);
      end
      if flag
          figure; plot(E);
      end
      meanE = mean(E);
      startflag=0;
      startnum=0;
      startframe=0;
      endframe = 0;
      S = [];
      for L = 1 : framenumber
          if E(L) > meanE
              startnum = startnum+1;
              if startnum == 2
                  startframe = L-2;
                  startflag = 1;
              end
          end
          if E(L) < meanE
              if startflag == 1
                  endframe = L-1;
                  S = [S; startframe endframe];
                  startflag = 0;
                  startnum = 0;
              end
          end
      end
      if size(S, 1) > 1
          ms = min(S(:, 1));
          es = max(S(:, 2));
      else
          ms = S(1);
          es = S(2);
      end
      
      MC = [];
      snum = 1;
      for i = ms : es
          si = (i-1)*framelength;
          ei = i*framelength;
          fi = signal(si:ei);
          mc = mfcc(fi,fs);
          MC{snum} = mc;
          snum = snum + 1;
      end
      

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?