Reply by kingdavid3 January 26, 20072007-01-26
I got it now

I used this 

mydir='Musicvoice\';

file=dir([mydir '*.wav']);

for i=1:length(file);

    [s, fs]=wavread([mydir file(i).name]);

    do something in here...............
end


Reply by Thomas Rachel January 26, 20072007-01-26
kingdavid3 wrote:


> file=dir('Musicvoice\*.wav'); > > for i=1:length(file); > % (1) > [s, fs]=wavread(file(i).name); > > commands statements etc, in here... > > end > > It gave me the error below. Please help. > > ??? Error using ==> wavread > Cannot open file. > > Error in ==> extractFeature at 16 > [s, fs]=wavread(file(i).name); %wavread function returns s and > the sampling frequency
What says disp(file(i).name) at this (1) place? Maybe the folder name Musicvoice isn't included in the file name array. Thomas -- Jabber-ID: glglgl@amessage.info (keine Email-Adresse!) Warum Jabber, was ist das und wie geht das? http://de.wikibooks.org/wiki/Jabber-Kompendium:_Schnelleinstieg
Reply by Alan Tan January 26, 20072007-01-26
Very possibly, the folder Musicvoice is not in the Matlab search path.
Add the directory to Matlab search path (use addpath() if you must)
before running your script and you should be good to go.

kingdavid3 wrote:
> This is a small part of my whole project (Speech/Music > Discrimination). I can wavread all the wave files when the code is in > the current directory. > > Using this > > file=dir('*.wav'); > > for i=1:length(file); > > [s, fs]=wavread(file(i).name); > > commands statements etc, in here... > > end > > The problem is i want to used this code to other folders without > moving it in that directory. For example there are wave files in the > Musicvoice folder I edited the code to something like this to access > the wave files in the Musicvoice. > > file=dir('Musicvoice\*.wav'); > > for i=1:length(file); > > [s, fs]=wavread(file(i).name); > > commands statements etc, in here... > > end > > It gave me the error below. Please help. > > ??? Error using ==> wavread > Cannot open file. > > Error in ==> extractFeature at 16 > [s, fs]=wavread(file(i).name); %wavread function returns s and > the sampling frequency
Reply by Brad Griffis January 26, 20072007-01-26
kingdavid3 wrote:
> This is a small part of my whole project (Speech/Music > Discrimination). I can wavread all the wave files when the code is in > the current directory. > > Using this > > file=dir('*.wav'); > > for i=1:length(file); > > [s, fs]=wavread(file(i).name); > > commands statements etc, in here... > > end > > The problem is i want to used this code to other folders without > moving it in that directory. For example there are wave files in the > Musicvoice folder I edited the code to something like this to access > the wave files in the Musicvoice. > > file=dir('Musicvoice\*.wav'); > > for i=1:length(file); > > [s, fs]=wavread(file(i).name); > > commands statements etc, in here... > > end > > It gave me the error below. Please help. > > ??? Error using ==> wavread > Cannot open file. > > Error in ==> extractFeature at 16 > [s, fs]=wavread(file(i).name); %wavread function returns s and > the sampling frequency
I don't know for sure but I would guess it's one of two things: 1) Perhaps Matlab doesn't like the '\' character, maybe it likes '/' instead. 2) The '\' character is often used as an escape character (e.g. \n etc.). I think if you want to have an actual '\' you might need to type it as '\\' or something similar. Hope that helps! Brad
Reply by kingdavid3 January 25, 20072007-01-25
This is a small part of my whole project (Speech/Music
Discrimination). I can wavread all the wave files when the code is in
the current directory.
 
Using this
 
file=dir('*.wav');
 
for i=1:length(file);
 
    [s, fs]=wavread(file(i).name);
 
    commands statements etc, in here...
 
end
 
The problem is i want to used this code to other folders without
moving it in that directory. For example there are wave files in the
Musicvoice folder I edited the code to something like this to access
the wave files in the Musicvoice.
 
file=dir('Musicvoice\*.wav');
 
for i=1:length(file);
     
    [s, fs]=wavread(file(i).name);
 
    commands statements etc, in here...
 
end
 
It gave me the error below. Please help.
 
??? Error using ==> wavread
Cannot open file.
 
Error in ==> extractFeature at 16
    [s, fs]=wavread(file(i).name); %wavread function returns s and
the sampling frequency