Voice Recognition Input Problem

4 次查看(过去 30 天)
Hasan Duyan
Hasan Duyan 2021-6-1
回答: Sameer 2024-5-24
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

回答(1 个)

Sameer
Sameer 2024-5-24
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

类别

Help CenterFile Exchange 中查找有关 Speech Recognition 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by