Clear Filters
Clear Filters

Audioread error with .wav file path on windows

5 views (last 30 days)
Hi I'm trying to read a .wav file but get an error message re the path. Have tried playing around with the '\' - what am I missing? I'm really new to MATLAB so really struggling !
FromDir= 'C:\Users\emily\Coding\vocal\output';
RawMicDir='C:\Users\emily\Coding\vocal\data';
SaveDir='C:\Users\emily\Coding\vocal\codedspeech';
filename='1001_1_1';
[Raw,Fs]=audioread(strcat(RawMicDir,filename,'.wav'));
Speakers=importdata(strcat(FromDir,filename,'.csv'));
VocDet=Speakers.textdata(2:end,1:2);
VocDet=str2double(VocDet);
savename=strcat(SaveDir,'\',filename,'coded.csv');
Error message:
Error using audioread>readaudio (line 130)
The filename specified was not found in the MATLAB path.
Error in audioread (line 123)
[y, Fs] = readaudio (filename, range, datatype);
Error in Speech_coding_Lev (line 20)
[Raw,Fs]=audioread(strcat(RawMicDir,filename,'.wav'));

Accepted Answer

Jan
Jan on 21 Feb 2022
Check this manually:
FromDir= 'C:\Users\emily\Coding\vocal\output';
RawMicDir='C:\Users\emily\Coding\vocal\data';
SaveDir='C:\Users\emily\Coding\vocal\codedspeech';
filename='1001_1_1';
strcat(RawMicDir,filename,'.wav')
ans = 'C:\Users\emily\Coding\vocal\data1001_1_1.wav'
% You want to insert a file separator between the folder and the path:
fullfile(RawMicDir, [filename,'.wav'])
Prefer fullfile instead of strcat.
  3 Comments
Jan
Jan on 22 Feb 2022
fullfile care about file separators e.g. to consider the operating system and to insert missing separators. Using strcat instead is a frequent source of bugs.

Sign in to comment.

More Answers (1)

Adelina
Adelina on 18 Apr 2024
FromDir= 'C:\Users\emily\Coding\vocal\output';
RawMicDir='C:\Users\emily\Coding\vocal\data';
SaveDir='C:\Users\emily\Coding\vocal\codedspeech';
filename='1001_1_1';
strcat(RawMicDir,filename,'.wav')
ans = 'C:\Users\emily\Coding\vocal\data1001_1_1.wav'
% You want to insert a file separator between the folder and the path:
fullfile(RawMicDir, [filename,'.wav'])

Categories

Find more on File Name Construction in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!