Voice Recognition Input Problem

3 vues (au cours des 30 derniers jours)
Hasan Duyan
Hasan Duyan le 1 Juin 2021
Réponse apportée : Sameer le 24 Mai 2024
As seen in the figures below, 2 FFT values were recorded to the "F" value by running the code twice. What we need to do is to create a VoiceTesting script and record a new voice the same as the code. and then print these newly recorded sound values to the screen, whichever is close to the values 553 and 694, which it has received from the database. The process we will do is a kind of voice recognition procedure used in the field of security. the newly recorded sound should choose whichever of the previous recordings is more similar. How can we write voice testing code?
CODE:
clear all; close all; clc;
%% 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 extension
f=VoiceFeatures(data);
f %% Save users data
uno=input('Enter your Name : ');
try load database F=[F;f];
C=[C;uno];
save database catch F=f; C=uno;
save database F C
end
f
msgbox('Your voice registered')
function [xPitch]=VoiceFeatures(data)
F = fft(data(:,1)); plot(real(F)); m=max(real(F)); xPitch=find(real(F)==m,1); end

Réponses (1)

Sameer
Sameer le 24 Mai 2024
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

Catégories

En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by