Audioread error "Undefined function 'wavread' for input arguments of type 'char'."
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I tried running the following code on versions R2020b, R2021a, R2022a both on matlab online and on desktop and get the same error. The following is in a for loop, below is the relevant code.
i=1:length(files
filename = files(i);
filelocation = ['audio/',filename.name]
[wave,Fs]=audioread(filelocation);
Error message:
Undefined function 'wavread' for input arguments of type 'char'.
Error in audioread (line 3)
[y,Fs] = wavread(filename);
Error in untitled (line 63)
[wave,Fs]=audioread(filelocation);
I did try running the audioread function separately with a single file and get the same error message. I'm at a total loss because this code worked totally fine for a friend using R2020b
2 Kommentare
KSSV
am 12 Mai 2022
filelocation = ['audio/',filename.name]
Is above line providing exact path to the file?
Antworten (1)
Siraj
am 20 Sep. 2023
Hi!
It appears that you are experiencing an issue while trying to read data from an audio file using the “audioread” function.
The issue might be specific to your environment or the specific audio file you are trying to read.
Check whether "filename.name" is a character array or a string scalar. Since the error message suggests that “wavread” is not defined for type “char”, try using a string scalar for the “filelocation”.
You can use the “fullfile” function to construct the file path, which handles file separators in a platform-independent way. Refer to the following link to know more about “fullfile” function.
To provide a clearer understanding, I have included an example code snippet below:
% Specify the filename
filename = "handle1.wav";
% Construct the file location using the fullfile function
filelocation = fullfile("Audio", filename);
% Read the audio file using the audioread function
[wave, Fs] = audioread(filelocation);
Hope this helps.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!