Audioread error "Undefined function 'wavread' for input arguments of type 'char'."
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
KSSV
2022-5-12
filelocation = ['audio/',filename.name]
Is above line providing exact path to the file?
回答(1 个)
Siraj
2023-9-20
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Measurements and Spatial Audio 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!