Hi Hasan
From my understanding, you want to create a voice recognition script in MATLAB that records a new voice, extracts its FFT values, and compares them with existing FFT values (in your case, 553 and 694).
This script will help identify the closest match from the existing recordings to the newly recorded voice.
Here’s how you can achieve this:
%% Load the database
load database
%% Create a recorder object
recorder = audiorecorder(16000,8,2);
%% Record user's voice for 5 sec
disp('Please Record your voice');
drawnow();
pause(1);
recordblocking(recorder,5);
play(recorder);
data = getaudiodata(recorder);
plot(data)
figure;
%% Feature extraction
f_new = VoiceFeatures(data);
%% Compare the new voice with the existing voices
diffs = abs(F - f_new); % calculate the absolute difference between new and existing FFT values
[~, idx] = min(diffs); % find the index of the smallest difference
%% Display the result
disp(['The new voice is most similar to the voice of ', C{idx}]);
%% Function to extract voice features
function [xPitch]=VoiceFeatures(data)
F = fft(data(:,1));
plot(real(F));
m = max(real(F));
xPitch = find(real(F) == m, 1);
end
This script will load the existing FFT values and names from the “database”, record a new voice, extract its FFT value, and then find the most similar existing voice by comparing the FFT values. The name of the most similar voice will be displayed on the screen. Also, please ensure that the “database.mat” file is in the same directory as your script. If it’s not, you need to provide the full path to the file in the load function.
I hope this helps!
Sameer