Filter löschen
Filter löschen

Audioread error with .wav file path on windows

5 Ansichten (letzte 30 Tage)
Emu
Emu am 21 Feb. 2022
Beantwortet: Adelina am 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'));

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Kategorien

Mehr zu File Name Construction finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by