File Exchange

image thumbnail

Some Basic Audio Features

version 1.1.0.0 (88 KB) by Theodoros Giannakopoulos
Use the provided m-files for computing the features of an audio classification problem

14 Downloads

Updated 18 Mar 2014

View Version History

View License

---------------------------------------
Theodoros Giannakopoulos
http:/www.di.uoa.gr/~tyiannak
---------------------------------------
Feature extraction (as in most pattern recognition problems) is maybe the most important step in audio classification tasks. The provided Matlab code computes some of the basic audio features for groups of sounds stored in WAV files. Furthermore, a simple class separability measure, based on feature histograms is used for measuring the ability of each feature to be used for classifying the given classes. Therefore, you can use the provided m-files for computing the features of an audio classification problem (i.e. specific audio classes) and understanding "how good" those features are for the specific classification task.

The features are calculated in a two-step way:

In particular, the following audio features and respective statistics are extracted for each audio segment:
Features Statistics
Energy Entropy Standard Deviation (std)
Signal Energy Std by Mean (average) Ratio
Zero Crossing Rate Std
Spectral Rolloff Std
Spectral Centroid Std
Spectral Flux Std by Mean Ratio

In order to compute the 6 feature statistics for a specific .wav file, you can use the computeAllStatistics(fileName, win, step).

After the features are calculated,

a) the histograms of each feature for all classes are estimated

b) a simple algorithm is used for estimating the separability of the audio classes. In other words, a measure that describes how "easily" the features will be classified. In the case of a multi-class classification problem, the measure is calculated for EACH CLASS opposed to ALL OTHER CLASSES, i.e. a measure value FOR EACH CLASS is computed. The algorithm is described in detail in http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=18791&objectType=FILE#.

EXAMPLE:

The main function of this demo is computeFeaturesDirectory(). The only recuired argument is a cell array with the names of the directories in which the .wav files of the respective classes are stored. For example, suppose you have three folders named MUSIC, SPEECH and NOISE, each one containing wav files with relevant audio content (i.e. wav files of segments containing music, speech and noise). In order to compute the audio features of those files simply write:

>> F = computeFeaturesDirectory({'music','speech','noise'});

Theodoros Giannakopoulos
http:/www.di.uoa.gr/~tyiannak

* * * * * * * * * * * * * * * * * * * *
IMPORTANT UPDATE:
More advanced audio analysis methods can be found in the MATLAB AUDIO ANALYSIS LIBRARY (http://www.mathworks.com/matlabcentral/fileexchange/45831-matlab-audio-analysis-library) which is part of the book INTRODUCTION TO AUDIO ANALYSIS: A MATLAB APPROACH (http://www.amazon.com/Introduction-Audio-Analysis-MATLAB%C2%AE-Approach/dp/0080993885)
* * * * * * * * * * * * * * * * * * * *

Cite As

Theodoros Giannakopoulos (2020). Some Basic Audio Features (https://www.mathworks.com/matlabcentral/fileexchange/19236-some-basic-audio-features), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (21)

Katarina Vuckovic

How would I determine the window length?

Katarina Vuckovic

Hello,

I was able to resolve the problem by using a longer wave file. The first file I sued was only 2 seconds and the second one was 9 seconds.

Ahong Kazama

I am newbie , how to use the code ? To get the 6 features ?

SGUNITN

wavread is deprecated instead use audioread.

JOYDIP PANJA

sir
thanks for sharing with us. what is step and windowLength here ??

P G

vipul nanavare

is classname a directory?

Mathumitha. Ganesan

Z = zcr(signal,windowLength, step, fs)

how to calculate the window length for an audioclip Ex [d1,fs] = audioread('sm1.wav') n=length(d1)
step=ceil(20*fs/1000); %one spectral slice every 20 ms
windowlength=ceil(100*fs/1000); % 100 ms data window.
(output)d1 = 55604, fs = 16000
this is how we have to calculate windowlength and step . Is there any other method

Shruti Modak

I am facing this error : Output argument "Entropy" (and maybe others) not assigned during call to
"Energy_Entropy_Block".

Some help?

abu

Dear Gökhan Vural

I faced the same problem as yours. It turns out that you must have more than 8 files in each class directory to turn this error off. The number of files should actually be much more to get enough data points for reasonable histogram study.

----------------------------------
Error in ==> myHist at 20
while ((i1>=1) || (i2<=length(X)))

Error in ==> computeFeaturesDirectory at 68
[H,X] = myHist(tempF);

andrea

Munaza

Dear Author.. I want to run feature extraction to understand how can it be helpfull to me for doing my thesis of "getting voice out of songs so that my output will be the singing voice only".. can you please provide a Matlab code for doing this task.. Waiting for your kind reply.. thanks

fatemeh

These errors occurred in result of difference between sampling rate and bit rates of the input files. Also number of files should be more than 15. Provided this two condition, the code runs completely without error in MATLAB 7.8.0 (R2009a). Thank you Theodoros.

fatemeh

fatemeh

I've run the code as "F=computeFeaturesDirectory({'H'});"
,it gave me a number of Warnings and 3 Errors .. Here them all ..

>Warning: Integer operands are required for colon operator when used as index

> In SpectralRollOff at 9
In computeAllStatistics at 25
In computeFeaturesDirectory at 36
Warning: Rounding order to nearest integer.
> In signal\private\check_order at 28
In signal\private\gencoswin at 18
In hamming at 17
In SpectralCentroid at 6
In computeAllStatistics at 26
In computeFeaturesDirectory at 36
Warning: Integer operands are required for colon operator when used as index
> In SpectralCentroid at 8
In computeAllStatistics at 26
In computeFeaturesDirectory at 36
??? Error using ==> times
Matrix dimensions must agree.

Error in ==> SpectralCentroid at 10
window = H.*(signal(curPos:curPos+windowLength-1));

Error in ==> computeAllStatistics at 26
C = SpectralCentroid(x, win*fs, step*fs, fs);

Error in ==> computeFeaturesDirectory at 36
F = computeAllStatistics([classNames{c} '//' D(i).name], win, step);

by changing && to & it didn't correct.
window = H.*(signal(curPos:curPos+windowLength-1));

thanks for sharing the code.

sunshinechina

thanks for sharing with us,^_^

Thank you for your feedback.
The first is simply a warning, you can get rid of it by rounding the integer index in the respective line of code in file Energy_Entropy_Block.
As far as the error is concerned, please use single & and | instead of && and ||. Sorry for that (it works on my version of Matlab though). I will repair it in a later update.

Gökhan Vural

I've run the code as "F=computeFeaturesDirectory({'Hard','Jazz','Pop'});"
just to see outputs. However, it gave me a number of Warnings and 2 Errors .. Here thm all ..

***
Warning: Integer operands are required for colon operator when used as index
> In Energy_Entropy_Block at 18
In computeAllStatistics at 22
In computeFeaturesDirectory at 36
**
??? Operands to the || and && operators must be convertible to logical scalar values.

Error in ==> myHist at 20
while ((i1>=1) || (i2<=length(X)))

Error in ==> computeFeaturesDirectory at 68
[H,X] = myHist(tempF);

The output is an Empty Graphic, not like your sample jpg.
Should i do something different to run your code ?

Thx for sharing and help, Regards.

Heri Firmansyah

K. Idrank

daniel kong

it would be much better if each input and output were clearly noted and explained in each .m file.

walid hussein

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!