Changeset 1dae4eb for python/aubio/bench


Ignore:
Timestamp:
Dec 22, 2005, 5:50:37 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:
c32976a5
Parents:
af445db
Message:

new act_on_files, avoids using find too much; add some error checking
new act_on_files, avoids using find too much; add some error checking

File:
1 edited

Legend:

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

    raf445db r1dae4eb  
    7878                action("%s%s%s"%(respath,'/',s))
    7979
     80def act_on_files (action,listfiles,listres=None,suffix='.txt',filter='f',sub='\.wav$',**keywords):
     81        """ execute action(respath) an all subdirectories in respath """
     82        if listres and len(listfiles) <= len(listres):
     83                for i in listfiles:
     84                        action(i,listres[i],**keywords)
     85        else:
     86                for i in listfiles:
     87                        action(i,None,**keywords)
     88
    8089class bench:
    8190        """ class to run benchmarks on directories """
    8291        def __init__(self,datadir,resdir=None,checkres=False,checkanno=False):
    8392                self.datadir = datadir
     93                # path to write results path to
    8494                self.resdir = resdir
     95                # list of annotation files
     96                self.reslist = []
     97                # list used to gather results
    8598                self.results = []
    8699                print "Checking data directory", self.datadir
     
    90103       
    91104        def checkdata(self):
     105                if os.path.isfile(self.datadir):
     106                        self.dirlist = os.path.dirname(self.datadir)
     107                        print "DBG: found a file"
     108                elif os.path.isdir(self.datadir):
     109                        self.dirlist = list_dirs(self.datadir)
     110                        print "DBG: found a dir"
     111                # allow dir* matching through find commands?
     112                else:
     113                        print "ERR: path not understood"
     114                        sys.exit(1)
    92115                print "Listing directories in data directory",
    93                 self.dirlist = list_dirs(self.datadir)
    94116                if self.dirlist:
    95117                        print " (%d elements)" % len(self.dirlist)
     
    106128                        print "ERR: no sound files were found in", self.datadir
    107129                        sys.exit(1)
    108                 #for each in self.sndlist: print each
    109130       
    110131        def checkanno(self):
     
    132153                self.orig, self.missed, self.merged, self.expc, \
    133154                        self.bad, self.doubled = 0, 0, 0, 0, 0, 0
    134                 act_on_data(self.file_exec,self.datadir,self.resdir, \
     155                act_on_files(self.file_exec,self.sndlist,self.reslist, \
    135156                        suffix='',filter=sndfile_filter)
    136157       
Note: See TracChangeset for help on using the changeset viewer.