Male Female Voice Recognition

Recognize gender using audio

Featured image

This is a project which I made using MATLAB. As the title suggests it is a simple application which detects the gender of the person.

Prior Information Utilized:

Thus we set the threshold frequency to be 160Hz i.e. if the calculated frequency of the audio is more than 160Hz then it is Female voice and if less then it is Male voice.


In the above workflow, each frame is passed through a low pass filter so that only voice signal remains and rest is discarded. This help in increasing accuracy. For each frame mean is subtracted from all the values and then the zero-crossing method is used to find the frequency. At the end, the mean frequency of all the frames is compared with threshold frequency to identify the gender.

GUI Application:

Source button — Used to select the source file. By default, it is set to take in only .wav files(can be changed either in the source file)

Go button — After the selection from source button to finally select the file name shown in the box, press this button

Another way is directly writing the address of that file and pressing Go button.

In the Message box where in the “Upload New File” is shown provides step by step procedure and errors made by the user while selecting the file and processing it further.

Generate Graph — Generates the FFT graph of that audio file.

Calculate button — This button calculate the frequency using the algorithm proposed and using the inbuilt algorithm. Also it tells the gender.

Note- Even though the frequency does not match, the gender predicted is almost same in all the test cases.

Using the From Multimedia File block the sample audio is taken as input with 3500 samples per audio channel. This is passed to the next block where frequency of each frame is calculated. Following is the code for that function.

function y = fcn(x)
coder.extrinsic('butter');  % To include butter function in simulink
coder.extrinsic('filter');  % To include filter function in simulink
xin = abs(x);
xin = xin-mean(xin);
zc=length(find((xin>0 & x2<0) | (xin<0 & x2>0)));
y = 0.5*Fs*zc/length(x);

In the next block Persistent is used in order to save the previous result in order to use next time. This is essential for the calculation of mean frequency.


function [y,r1] = fcn(u,l)
persistent i
persistent r
if isempty(i)
        i = 0;
if isempty(r)
        r = 0;
i= (u/j)+i;
y = i;

In the final block values are compared with the threshold values.

function y = fcn(x,r,l)
if r>l/3500
    if x>160

As final result frequency is displayed also

0 - Male
1 - Female


Future Scope:

Use Machine Learning to classify different voices and then generate more accurate results.

For complete project visit-