Hi Vineeth,
The code involves functions and scripts to read, play, and analyze a .wav audio file to determine the gender based on the fundamental frequency (Fx).
I assume that the audio file you are working with contains a clear speech signal for accurate gender detection.
Here is the explanation for the important sections of the code:
File Selection and Audio Reading:
The code uses uigetfile to prompt the user to select a .wav file. If a file is selected, audioread reads the audio data and sample rate.
[file_name, file_path] = uigetfile({'*.wav'});
[y, fs] = audioread(filename);
Playing the Audio:
The wavplay function is defined to play the audio using the "audioplayer" object. It plays the signal at the specified sample rate.
player = audioplayer(signal, sampleRate);
playblocking(player);
Gender Detection Logic:
The gen_det_sph function calculates the autocorrelation of the audio signal and uses it to estimate the fundamental frequency (Fx). Based on Fx, it categorizes the signal as male or female.
r = xcorr(x, ms20, 'coeff');
[rmax, tx] = max(r(ms2:ms20));
Fx = fs/(ms2+tx-1);
Result Display:
The code uses msgbox to display the detected gender or any issues (e.g., no signal recorded). The frequency is rounded and shown in the message box.
if Fx <= 175 && Fx >= 80
msgboxText{1} = 'Male';
elseif Fx > 175 && Fx <= 255
msgboxText{1} = 'Female';
else
msgboxText{1} = 'Sorry not recognized';
Plotting:
The waveform of the audio signal and its autocorrelation are plotted using plot, providing a visual representation of the signal and its analysis.
plot(t, y);
plot(d, r);
Refer to the documentation of "audioplayer": https://www.mathworks.com/help/matlab/ref/audioplayer.html
Refer to the documentation of "xcorr": https://www.mathworks.com/help/signal/ref/xcorr.html
Hope this helps!
