Audioread cannot find WAV file

8 views (last 30 days)
Hello,
we are trying to load a WAV audio file into matlab for filtering. Oddly, It cannot seem to load the audio file without running into an incorrect path error. I have tried resetting the userpath and have also tried specifying the exact file location of audiofile instead of the file name. I have also tried turning the file location into a string variable named file but the results are the same. I am a bit puzzled in terms of what I might be doing wrong.
userpath("C:\Users\Jerry\Desktop\eeglab_current\eeglab2019_1")
[y,Fs] = audioread("PLEAS_43s_Male_Laugh")

Accepted Answer

Star Strider
Star Strider on 19 Dec 2019
It is likely most efficient to use the fullfile function to identify the file.
Settting the userpath may not be doing what you believe it is doing.
Also, for best results, include the extension:
[y,Fs] = audioread("PLEAS_43s_Male_Laugh.wav")
Obviously I cannot test this, so I am posting it as UNTESTED CODE.

More Answers (1)

Image Analyst
Image Analyst on 20 Dec 2019
Try this:
folder = 'C:\Users\Jerry\Desktop\eeglab_current\eeglab2019_1';
baseFileName = 'PLEAS_43s_Male_Laugh.wav'; % Include extension
fullFileName = fullfile(folder, baseFileName)
[y, Fs] = audioread(fullFileName); % Read into array
sound(y, Fs); % Play it

Categories

Find more on MATLAB Mobile in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!