Borrar filtros
Borrar filtros

Audioread error with .wav file path on windows

5 visualizaciones (últimos 30 días)
Emu
Emu el 21 de Feb. de 2022
Respondida: Adelina el 18 de Abr. de 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'));

Respuesta aceptada

Jan
Jan el 21 de Feb. de 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 comentarios
Jan
Jan el 22 de Feb. de 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 el 22 de Feb. de 2022
I see - thank you for the reply !

Iniciar sesión para comentar.

Más respuestas (1)

Adelina
Adelina el 18 de Abr. de 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'])

Categorías

Más información sobre File Name Construction en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by