read random .wav in MATLAB

Sir, I'm Patty Kotta, I want to develop a MATLAB program for reading a .wav file randomly from a group of .wav files. If anyone know the program , please send me & i'll be very thankful to you.
Your's Faithfully
PATTY KOTTA

Respuestas (2)

Andreas Goser
Andreas Goser el 29 de Feb. de 2012

0 votos

No full code, but the hint to use the commands DIR, RAND and WAVREAD.
With DIR, you can receive all WAV files in a certain diretory. If you design a randon number so that it spans over the number of all files, then you just have to import them.
Jan
Jan el 29 de Feb. de 2012

0 votos

List = dir(fullfile(PathName, '*.wav'));
Index = randi(length(List), 1);
File = fullfile(PathName, List(Index).name);
S = wavread(File);

4 comentarios

Andreas Goser
Andreas Goser el 29 de Feb. de 2012
I thought you were in favor of coaching vs. providing code ;-)
Senem Gokpinar
Senem Gokpinar el 27 de Dic. de 2020
Hello, I was searching for the same problem as above and I saw your answer. I already wrote a program to discriminate an audio (10 words speech) and used audiowrite to save each of the words individually as .wav files. Now I am trying to create random sentences with that 10 words but when I use the code that you suppied, It returns only a word, not a sentence. Do you have any idea to fix this?
Jan
Jan el 27 de Dic. de 2020
Editada: Jan el 27 de Dic. de 2020
If you provide your code, fixing it is much easier. A bold guess:
List = dir(fullfile(PathName, '*.wav'));
Index = randperm(numel(List));
for k = 1:numel(List)
File = fullfile(PathName, List(Index(k)).name);
S = wavread(File);
... So what do you want with the loaded data?
end
Note that wavread is not available anymore in modern Matlab versions. Use audioread instead.
Senem Gokpinar
Senem Gokpinar el 28 de Dic. de 2020
Thank you. When I use that code as
List = dir(fullfile('C:\Users\hp\Desktop\Words', '*.wav'));
Index = randperm(numel(List));
for k = 1:numel(List)
File = fullfile('C:\Users\hp\Desktop\Words', List(Index(k)).name);
S =audioread(File);
sound(S,fs)
end
It sounds 3 words out of 10 at the same time, not in the order, unfortunatelly..

Iniciar sesión para comentar.

Categorías

Preguntada:

el 29 de Feb. de 2012

Comentada:

el 28 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by