Ignore:
Timestamp:
Dec 19, 2005, 9:56:54 PM (19 years ago)
Author:
Paul Brossier <piem@altern.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
7c9ad74
Parents:
b7eb9a5
Message:

extend bench, make it less error prone
extend bench, make it less error prone

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/bench/node.py

    rb7eb9a5 r50e99cc  
    2020
    2121def list_files(datapath,filter='f', maxdepth = -1):
     22        if not os.path.exists(datapath):
     23                print
     24                print "ERR: no directory %s were found" % datapath
     25                sys.exit(1)
    2226        if maxdepth >= 0: maxstring = " -maxdepth %d " % maxdepth       
    2327        else: maxstring = ""
     
    2832        return list_files(datapath, filter="f -name '*.wav'",maxdepth = maxdepth)
    2933
     34sndfile_filter = "f -name '*.wav' -o -name '*.aif' -o -name '*.aiff'"
     35
    3036def list_snd_files(datapath,maxdepth = -1):
    31         return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif'",
     37        return list_files(datapath, filter=sndfile_filter,
    3238                maxdepth = maxdepth)
    3339
     
    7379
    7480class bench:
    75 
     81        """ class to run benchmarks on directories """
    7682        def __init__(self,datadir,resdir=None,checkres=False,checkanno=False):
    7783                self.datadir = datadir
     
    8692                print "Listing directories in data directory",
    8793                self.dirlist = list_dirs(self.datadir)
    88                 print " (%d elements)" % len(self.dirlist)
    89                 #for each in self.dirlist: print each
     94                if self.dirlist:
     95                        print " (%d elements)" % len(self.dirlist)
     96                else:
     97                        print " (0 elements)"
     98                        print "ERR: no directory %s were found" % self.datadir
     99                        sys.exit(1)
    90100                print "Listing sound files in data directory",
    91101                self.sndlist = list_snd_files(self.datadir)
    92                 print " (%d elements)" % len(self.sndlist)
     102                if self.sndlist:
     103                        print " (%d elements)" % len(self.sndlist)
     104                else:
     105                        print " (0 elements)"
     106                        print "ERR: no sound files were found in", self.datadir
     107                        sys.exit(1)
    93108                #for each in self.sndlist: print each
    94109       
     
    113128                print
    114129
     130        def dir_exec(self):
     131                """ run file_exec on every input file """
     132                self.orig, self.missed, self.merged, self.expc, \
     133                        self.bad, self.doubled = 0, 0, 0, 0, 0, 0
     134                act_on_data(self.file_exec,self.datadir,self.resdir, \
     135                        suffix='',filter=sndfile_filter)
     136       
     137        def dir_eval(self):
     138                pass
     139
     140        def file_exec(self):
     141                pass
     142       
     143        def file_eval(self):
     144                pass
     145       
     146        def file_plot(self):
     147                pass
     148
     149        def dir_plot(self):
     150                pass
     151       
     152        def run_bench(self):
     153                for mode in self.modes:
     154                        self.params.mode = mode
     155                        self.dir_exec()
     156                        self.dir_eval()
     157                        self.dir_plot()
Note: See TracChangeset for help on using the changeset viewer.