Azzera filtri
Azzera filtri

Audioread error with .wav file path on windows

5 visualizzazioni (ultimi 30 giorni)
Emu
Emu il 21 Feb 2022
Risposto: Adelina il 18 Apr 2024
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'));

Risposta accettata

Jan
Jan il 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 Commenti
Jan
Jan il 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.
Emu
Emu il 22 Feb 2022
I see - thank you for the reply !

Accedi per commentare.

Più risposte (1)

Adelina
Adelina il 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'])

Categorie

Scopri di più su File Name Construction in Help Center e File Exchange

Tag

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by