Effacer les filtres
Effacer les filtres

Audioread error with .wav file path on windows

5 vues (au cours des 30 derniers jours)
Emu
Emu le 21 Fév 2022
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'));

Réponse acceptée

Jan
Jan le 21 Fév 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 commentaires
Jan
Jan le 22 Fév 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.
Emu
Emu le 22 Fév 2022
I see - thank you for the reply !

Connectez-vous pour commenter.

Plus de réponses (1)

Adelina
Adelina le 18 Avr 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'])

Catégories

En savoir plus sur File Name Construction dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by