VOICE Recognition Using MATLAB

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

Voice Recognition Using MATLAB

Muhammad Wasim
Muhammad Muneeb
Registration No:2018357
Registration No:2018304
Department of Electrical Engineering, GIKI
Department of Electrical Engineering, GIKI
III. WORKING OF CODE
Abstract— The aim of the CEP was to develop an algorithm The algorithm works in the following manner first to read
in MATLAB which could identify the gender of the speaker audio signals directly from the microphone, MATLAB has a
based on its frequency, in order to achieve it we employed command format:
the auto-correlation technique and achieve successful x=wavrecord(n, fs) so we first record the samples using it
results. A GUI was also developed using app designer on The n is the number of samples to be recorded and fs is the
MATLAB to make the process user friendly. sampling frequency. The Fs is taken as 8000 for sample 1
and 6000 for sample 2. The Fs value should be in a limit so
Keywords—MATLAB, frequency, gender, speaker, GUI that MATLAB can easily sample out the voice signal.
(Graphical Use Interface)
To write an audio file, following command is used:
I. INTRODUCTION wavwrite(x, fs, file_name)
The file_name= ‘test.wav’ or any name that you want and x
The aim of the CEP was to perform biometrics using the is the audio signal.
voice samples in order to achieve the purpose equal number
of voices of a Male and female were recorded and a For reading an audio file:
MATLAB program was written to differentiate between the
[y,fs] = audioread(‘m1.wav’)
male and female voices. A GUI was also created for this
application.
Here y is the audio signal’s amplitude and Fs being the
Signal is a physical quantity that varies with respect to the sampling rate.
independent variable like time, space, etc. Signal values can
be represented in zero’s and one’s. Processing of digital To record audio in MATLAB we will use the following
signal by using digital computer is called as Digital Signal command
Processing. According to Webster’s dictionary, speech is the
expression or communication throughout in speakers. Speech arObj=audiorecorder(Fs, nbits, nChannels)
is the most important thing to express our thoughts. Speech
signal is used to communicate among people. It not only
Here Fs is the same sampling rate, nChannels is the number
consists of the information but also carries the information
of channels being used and nbits is the data type. This
regarding the particular speaker. From which the speaker is
male or female can be recognized. command creates an audio object.

It records audio from an input device, such as a microphone


II. LITERATURE REVIEW connected to your system in the object, for the number of
A lot of research and work is currently being carried out on seconds specified by length.
the voice recognition using GR. Different Algorithms have
been developed by researchers for perfect recognition of To stop recording audio in the object created by the
female or male voices. It is currently use in ASR software audiorecorder, following command is used:
(Automatic Software Recognition). recordblocking(arObj, length)
The meaning of Gender Recognition (GR) is recognizing the
gender of the person whether the speaker is male or female. To store the recorded audio signal in a numeric way,
The Information about gender, age, ethnicity, and emotional following command is used:
state are the important ingredients that give rich behavioral y = getaudiodata(arObj)
information. Such information can be obtained from the It will return the recorded audio signal in the form of double
speech signal. In this project, an unknown speaker is
array.
compared to a database of some known speakers.
All the above-mentioned commands were related to audio
The best matching system is taken as the recognition analysis, now we are going to link these terms with the
decision. From the Recognition decision we conclude gender classification.
whether the given voice sample is generated by a male or To start with the classification, an important term which is
female. being used here is “autocorrelation.”
Correlation is normally used in signal processing, where you Autocorrelation – It is also known as serial correlation or
need to compare two signals and need to find the similarity cross-correlation of a signal with itself at different points in
between them. It is also known as the dot product of those time (that is what the cross stands for). Informally, it is the
similarity between observations as a function of the time lag
between them. MATLAB has a built-in command for this:
two signals. Correlation has many uses and you can read r = xcorr(x,y)
more about it on its Wiki Page. Correlation is also used for It returns the cross-correlation of two discrete-time
pattern recognition like you want to find some pattern in the sequences, x and y. Cross-correlation measures the
signal then you can use Correlation, In this project, we are similarity between x and shifted (lagged) copies of y as a
using correlation to find similarities between our stored function of the lag.
signals and the testing signal..
IV. GUI (GRAPHICAL USER INTERFACE)
fprintf('Plotting the waveform…\n');
The GUI was also made for the process to be user friendly in
order to achieve the purpose we used the app development y1=getaudiodata(rec1); % Get audio
technique in the MATLAB, first a button records the sample sample data
from the first speaker and the graph is also displayed, after audiowrite('test1.wav',y1,fs1);
this the sample from the second speaker is also recorded and
the second graph is plotted in the MATLAB and the gender rec2=audiorecorder(fs2, nbits, nChannels);
is also displayed.
fprintf('start of 5s recording… PLEASE SPEAK
FOR SECOND VOICE SAMPLE');
recordblocking(rec2, duration);

fprintf('Finished recording.\n');

fprintf('Plotting the waveform…\n');

y2=getaudiodata(rec2); % Get audio


sample data
audiowrite('test2.wav',y2,fs2);

ms1 = fs1/500;

ms10 = fs1/50;

r = xcorr(y1, ms10, 'coeff');

d1 = (-ms10:ms10)/fs1;

figure(1)

plot(d1, r);

title('Autocorrelation');
V. MATLAB CODE
xlabel('Delay (s)');

ylabel('Correlation coeff.');
fs1=8000; % Sampling
rate
r = r(ms10 + 1 : 2*ms10+1);
fs2=7500;
nbits=16;
[rmax, tx] = max(r(ms1:ms10));
nChannels=1;
duration=5; % Recording
Fx1 = fs1/(ms1+tx-1);
duration
rec1=audiorecorder(fs1, nbits, nChannels);
ms2 = fs2/500;
fprintf('start of 5s recording… PLEASE SPEAK
FOR FIRST VOICE SAMPLE');
ms20 = fs2/50;
recordblocking(rec1, duration);
fprintf('Finished recording.\n');
r = xcorr(y2, ms20, 'coeff');

d2 = (-ms20:ms20)/fs2; ylabel('Correlation coeff.');


figure(2)
plot(d2, r); r = r(ms20 + 1 : 2*ms20+1);
[rmax, tx] = max(r(ms2:ms20));
title('Autocorrelation'); Fx2 = fs2/(ms2+tx-1);

Fth= 200;
xlabel('Delay (s)'); if Fx1> Fth
disp('It is a female voice!')
else
disp('It is a male voice!') [1] https://www.mathworks.com/matlabcentral/answers/164116-how-to-
gender-recognition-with-fft)
end
[2] HTTPS://XPERTSVISION.WORDPRESS.COM/2015/12/04/GEND
if Fx2> Fth ER-RECOGNITION-BY-VOICE-ANALYSIS/
disp('It is a female voice!') [3] HTTPS://WWW.SLIDESHARE.NET/RONWINSTANMAY/GEND
ER-DETECTION-USING-MATLAB
else [4] HTTPS://MATLABSPROJECT.BLOGSPOT.COM/2019/10/AUTO
disp('It is a male voice!') MATIC-GENDER-RECOGNITION-SYSTEM.HTML
HTTPS://HARSHMITTAL2210.MEDIUM.COM/MALE-FEMALE-
VOICE-RECOGNITION-B95022AE87B3
end
REFERENCES

You might also like