【问题标题】:How to get mfcc features with octave如何使用 octave 获得 mfcc 功能
【发布时间】:2015-08-14 02:42:12
【问题描述】:

我的目标是在 octave 上创建加载音频文件(wav、flac)的程序,计算其 mfcc 特征并将它们作为输出提供。问题是我对 octave 没有太多经验,无法让 octave 加载音频文件,这就是为什么我不确定提取算法是否正确的原因。是否有加载文件并获取其功能的简单方法?

【问题讨论】:

  • 您到底尝试了什么,什么不起作用?请注意,Octave 4.0.0 是最新版本,其主要功能之一是支持音频。

标签: signal-processing octave speech-recognition mfcc


【解决方案1】:

您可以在八度音程中运行 RASTAMAT 的 mfcc 代码,您只需要修复一些东西,修复版本可供下载here

更改是为了在 powspec.m 中正确设置窗口

  WINDOW = hanning(winpts);

并修复与Matlab不兼容的specgram函数中的bug

【讨论】:

  • 谢谢。但是在尝试以八度音阶加载 *.m 文件时出现错误。有什么建议吗?
  • 很难向您提出任何建议,因为您没有提供任何有关错误的信息。
  • @NikolayShmyrev 我知道这是一个旧的,但提供给源代码的链接已经失效。您能否提供替代链接或将代码发布到其他地方?
  • 由 Sunil Kopparapu 博士发现这个其他代码:sites.google.com/site/sunilkopparapu/Home/asks(引用于“在 Octave 中计算 MFCC”视频:youtube.com/watch?v=oTI6c87M3Gs
  • Dropbox 链接已失效。 404!
【解决方案2】:

https://github.com/jagdish7908/mfcc-octave查看用于计算 MFCC 的 Octave 函数

有关计算 MFCC 的详细理论,请参阅 http://practicalcryptography.com/miscellaneous/machine-learning/guide-mel-frequency-cepstral-coefficients-mfccs/

 function frame = create_frames(y, Fs, Fsize, Fstep)
  N = length(y);
  % divide the signal into frames with overlap = framestep
  samplesPerFrame = floor(Fs*Fsize);
  samplesPerFramestep = floor(Fs*Fstep);
  i = 1;
  frame = [];
  while(i <= N-samplesPerFrame)
    frame = [frame y(i:(i+samplesPerFrame-1))];
    i = i+samplesPerFramestep;
  endwhile
  return 
 endfunction

function ans = hz2mel(f)
  ans = 1125*log(1+f/700);
  return
 endfunction

 function ans = mel2hz(f)
  ans = 700*(exp(f/1125) - 1);
  return
 endfunction

function bank = melbank(n, min, max, sr)
  % n = number of banks
  % min = min frequency in hertz
  % max = max frequency in hertz 
  % convert the min and max freq in mel scale
  NFFT = 512;
  % figure out bin value of min and max freq
  minBin = floor((NFFT)*min/(sr/2));
  maxBin = floor((NFFT)*max/(sr/2));
  % convert the min, max in mel scale
  min_mel = hz2mel(min);
  max_mel = hz2mel(max);
  m = [min_mel:(max_mel-min_mel)/(n+2-1):max_mel];
  %disp(m);
  h = mel2hz(m);
  % replace frequencies in h with thier respective bin values
  fbin = floor((NFFT)*h/(sr/2));

  %disp(h);
  % create triangular melfilter vectors
  H = zeros(NFFT,n);
  for vect = 2:n+1
    for k = minBin:maxBin
      
      if k >= fbin(vect-1) && k <= fbin(vect)
        H(k,vect) = (k-fbin(vect-1))/(fbin(vect)-fbin(vect-1));  
      elseif k >= fbin(vect) && k <= fbin(vect+1)
        H(k,vect) = (fbin(vect+1) - k)/(fbin(vect+1)-fbin(vect));
      endif
      
    endfor
  endfor
  bank = H;
  return
 endfunction     

clc;
clear all;
close all;
pkg load signal;

% record audio
Fs = 44100;
y = record(3,44100);
% OR %
% Load existing file
%[y, Fs] = wavread('../FILE_PATH/');
%y = y(44100:2*44100);
 
 % create mel filterbanks
 minFreq = 500;   % minimum cutoff frequency in Hz
 maxFreq = 10000;   % maximum cutoff frequency in Hz
% melbank(number_of_banks, minFreq, mazFreq, sampling_rate)
 foo = melbank(30,minFreq,maxFreq,Fs);

 % create frames
 frames = create_frames(y, Fs, 0.025, 0.010);
 % calculate periodogram of each frame
 NF = length(frames(1,:));
 [P,F] = periodogram(frames(:,1),[], 1024, Fs);
 % apply mel filters to the power spectra
 P = foo.*P(1:512);
 % sum the energy in each filter and take the logarithm
 P = log(sum(P));
 % take the DCT of the log filterbank energies
 % discard the first coeff 'cause it'll be -Inf after taking log
 L = length(P);
 P = dct(P(2:L));
 PXX = P;

 for i = 2:NF
  P = periodogram(frames(:,i),[], 1024, Fs);
   % apply mel filters to the power spectra
  P = foo.*P(1:512);
  % sum the energy in each filter and take the logarithm
  P = log(sum(P));
  % take the DCT of the log filterbank energies
  % discard the first coeff 'cause it'll be -Inf after taking log
  P = dct(P(2:L));
  % coeffients are stacked row wise for each frame
  PXX = [PXX; P];
 endfor
 % stack the coeffients column wise
 PXX = PXX';
 plot(PXX);

【讨论】:

  • 欢迎来到 SO!不要发布指向网站的链接,因为它可能会在将来被破坏或删除。相反,请解释解决方案。
猜你喜欢
  • 2017-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-15
  • 1970-01-01
  • 1970-01-01
  • 2018-04-13
  • 2014-04-03
相关资源
最近更新 更多