Input arguments must be 'double'

조회 수: 3 (최근 30일)
David Costa
David Costa 2018년 2월 16일
답변: Ritikh Deo 2022년 8월 29일
Hi, I'm doing a speech recognition code with neural networks fot the purpose of doing voice commands. When I try to determine the coefficients of a forward linear predictor with LPC function it gives me this error : "Input arguments must be 'double'". Parte of the code I have is
for i= 1:1:samp
fprintf('say AHEAD immediately after hitting enter');
input('');
x= audiorecorder(Fs, 16,2);
[s(i,:),g] = lpc(x,12); % 12+1 features
%plot(s(i,:));
end
Can anyone help me?
  댓글 수: 2
Guillaume
Guillaume 2018년 2월 16일
편집: Guillaume 2018년 2월 16일
What is F ?
David Costa
David Costa 2018년 2월 16일
Hi Guillaume, thank you for the answering. I forgot to say that F is the audiorecorder.

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

채택된 답변

Guillaume
Guillaume 2018년 2월 16일
If x is an audiorecorder object it's no wonder you get this error. You need to use the object to actually record and then get the recorded data, something like
recorder = auiorecorder(Fs, 16, 2);
input('say AHEAD immediately after hitting enter');
recorder.recordblocking(2); %to record for 2 seconds
[s(i, i), g] = lpc(recorder.getaudiodata, 12);

추가 답변 (1개)

Ritikh Deo
Ritikh Deo 2022년 8월 29일
clc;
close all;
clear all;
Fs=8000;
Nseconds = 1;
samp=6;
words=5;
for i= 1:1:samp
fprintf('say AHEAD immediately after hitting enter');
input('');
recorder = audiorecorder;%(Fs, 16, 1);
recordblocking(recorder,2); %to record for 2 seconds
s(i,:)= (getaudiodata(recorder));
%[s(i, :), g] = lpc(getaudiodata(recorder));
%x= wavrecord(Nseconds*Fs,Fs,'double');
%[s(i,:),g] = lpc(x,12); % 12+1 features
%plot(s(i,:));
end
for i= (samp+1):1:2*samp
fprintf('say STOP immediately after hitting enter');
input('');
recorder = audiorecorder(Fs, 16, 1);
recordblocking(recorder,2); %to record for 2 seconds
s(i,:)= (getaudiodata(recorder));
%[s(i, :), g] = lpc(getaudiodata(recorder));
%x= wavrecord(Nseconds*Fs,Fs,'double');
%[s(i,:),g] = lpc(x,12); % 12+1 features
%plot(s(i,:));
end
for i= (2*samp+1):1:3*samp
fprintf('say BACK immediately after hitting enter');
input('');
recorder = audiorecorder(Fs, 16, 1);
recordblocking(recorder,2); %to record for 2 seconds
s(i,:)= (getaudiodata(recorder));
%[s(i, :), g] = lpc(getaudiodata(recorder));
%x= wavrecord(Nseconds*Fs,Fs,'double');
%[s(i,:),g] = lpc(x,12); % 12+1 features
%plot(s(i,:));
end
for i= (3*samp+1):1:4*samp
fprintf('say LEFT immediately after hitting enter');
input('');
recorder = audiorecorder(Fs, 16, 1);
recordblocking(recorder,2); %to record for 2 seconds
s(i,:)= (getaudiodata(recorder));
%[s(i, :), g] = lpc(getaudiodata(recorder));
%x= wavrecord(Nseconds*Fs,Fs,'double');
%[s(i,:),g] = lpc(x,12); % 12+1 features
%plot(s(i,:));
end
for i= (4*samp+1):1:5*samp
fprintf('say RIGHT immediately after hitting enter');
input('');
recorder = audiorecorder(Fs, 16, 1);
recordblocking(recorder,2); %to record for 2 seconds
%[s(i, :), g] = lpc(getaudiodata(recorder));
%x= wavrecord(Nseconds*Fs,Fs,'double');
%[s(i,:),g] = lpc(x,12); % 12+1 features
%plot(s(i,:));
end
% for i= (5*samp+1):1:6*samp
%
% fprintf('say sLOW immediately after hitting enter');
% input('');
% x= wavrecord(Nseconds*Fs,Fs,'double');
% [s(i,:),g] = lpc(x,12); % 12+1 features
% plot(s(i,:));
% end
%
% for i= (6*samp+1):1:7*samp
%
% fprintf('say SPEED immediately after hitting enter');
% input('');
% x= wavrecord(Nseconds*Fs,Fs,'double');
% [s(i,:),g] = lpc(x,12); % 12+1 features
% plot(s(i,:));
% end
S=zeros(1,13);
for i=1:1:samp
S=cat(1,S,s(i,:));
S=cat(1,S,s(samp+i,:));
S=cat(1,S,s(2*samp+i,:));
S=cat(1,S,s(3*samp+i,:));
S=cat(1,S,s(4*samp+i,:));
% S=cat(1,S,s(5*samp+i,:));
% S=cat(1,S,s(6*samp+i,:));
end
S(1,:)=[];
%S=[s(1,:);s(17,:);s(33,:); s(2,:);s(18,:);s(34,:); s(3,:);s(19,:);s(35,:); s(4,:);s(20,:);s(36,:); s(5,:);s(21,:);s(37,:); s(6,:);s(22,:);s(38,:); s(7,:);s(23,:);s(39,:); s(8,:);s(24,:);s(40,:);s(9,:);s(25,:);s(41,:);s(10,:);s(26,:);s(42,:);s(11,:);s(27,:);s(43,:);s(12,:);s(28,:);s(44,:);s(13,:);s(29,:);s(45,:);s(14,:);s(30,:);s(46,:);s(15,:);s(31,:);s(47,:);s(16,:);s(32,:);s(48,:)]; %48 X 13 matrix
save speechp.mat S

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by