Error while recording using audio recorder object

4 views (last 30 days)
Everytime I work with this code, I'm getting errors like this.I'm not unable to rectify the problem and solve it.Could anybody please help?
How can I give the audiodata to ffname?
Error using audioread>readaudio (line 143)
The filename specified was not found in the MATLAB path.
Fs=8000;
ch=1;
nbits=16;
Nseconds=5;
recorder=audiorecorder(Fs,nbits,ch);
disp('Start speaking..')
recordblocking(recorder,Nseconds);
disp('End of Recording.');
record_file=getaudiodata(recorder);
ffname = sprintf('%s%s',record_file);
[st_dat,fs1] = audioread(ffname);
st_speech = resample(st_dat,fs,fs1);
st_y(1,:) = pyulear(st_speech,order,nfft,fs);

Accepted Answer

Jan
Jan on 16 Sep 2021
record_file=getaudiodata(recorder);
ffname = sprintf('%s%s',record_file);
getaudiodata replies a numerical array with the signal. The name with the part "file" is missleading. Then you try to convert this array to a string using %s%s as format. Afterwards you try to use this string as a file name, but of course there is no such file.
Why do you try a read a file at all, if you do have the signal already?

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!