필터 지우기
필터 지우기

Why the wav or audio is repeating eventhough I record a new voice. please help me I cant hear my new audio it plays the same audio over again.

조회 수: 3 (최근 30일)
clc
clear all
close all
warning off
Fs=8000;%Sampling frequency in hertz
ch=1;%Number of channels--2 options--1 (mono) or 2 (stereo)
datatype='uint8';
nbits=16;%8,16,or 24
Nseconds=5;
NumS = 5;
%% Create a recorder object
recorder=audiorecorder(Fs,nbits,ch);
datatype='uint8';
%% Record user's voice for 5 sec
disp('Get Ready')
pause(3)
% to record audio data from an input device ...
...such as a microphone for processing in MATLAB
recorder=audiorecorder(Fs,nbits,ch);
disp('Start speaking...')
%Record audio to audiorecorder object,...
...hold control until recording completes
recordblocking(recorder,Nseconds);
disp('End of Recording.');
disp('Recorded');
%Store recorded audio signal in numeric array
x=getaudiodata(recorder,datatype);
%%Training Function
f = voiceFeatures(x);
%%Save Users data
user = cellstr(input('Enter the users name:', 's'));
try
load database
F=[F;f];
C=[C;user];
if numel(F) > 5
F = F(end-4:end);
C = C(end-4:end);
end
save database
catch
F=f;
C=user;
save database F C
end
%Write audio file
[filename, pathname] = uiputfile('*.wav', 'File name for output');
if isnumeric(filename); return; end %user cancel
fullname = fullfile(pathname, filename);
audiowrite(fullname, x, Fs)
%%Training Function
f = voiceFeatures(x);
%%Play users voice
play(recorder);
x= getaudiodata(recorder);
%Store recorded audio signal in numeric array
data=getaudiodata(recorder,datatype);
plot(x)
figure;
disp('done.')
msgbox('Your voice is registered')
  댓글 수: 12
kim
kim 2022년 12월 21일
like this eventhough I didnt write hello in my user when I register it
Jan
Jan 2022년 12월 22일
편집: Jan 2022년 12월 22일
@kim: I've showed you above, how your code can be simplified. Why do you ignore such suggestions?
You display C(index) as output, although C is not created in the code anywhere. Therefore it must be part of the loaded MAT file.
Do not load the contents of a MAT file directly to the workspace, because this provokes such problems frequently. Store the output in a variable instead:
db = load('database.mat');
[smallest_distance, index] = min(abs(db.F - f_test));
Clean up the contents of the database.mat file. It looks like it contains a lot of junk like "NumS" and "Nseconds". Having a bunch of redundant variables increases the confusion level. Files like "colee..wav" and "COLEE.WAV" are a trap also. You do see, that you loose the overview already in a script with 50 lines. So avoid every addition source of troubles: Keep your workspace clean.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Speech Recognition에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by