Changeset 0029638 for python/bench-pitch


Ignore:
Timestamp:
Dec 16, 2005, 8:34:52 AM (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:
b7eb9a5
Parents:
50791b3
Message:

add class task, rewrite of bench-pitch
add class task, rewrite of bench-pitch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/bench-pitch

    r50791b3 r0029638  
    11#! /usr/bin/python
    22
    3 #from conf.aubio_benchrc import *
    4 from aubio.bench.config import *
    53from aubio.bench.node import *
    6 import os
     4from aubio.tasks import *
    75
    8 datapath = "%s%s" % (DATADIR,'/pitch/isolated/piano/011pfnof')
    9 respath = '/var/tmp/isolated/testing'
     6class benchpitch(bench):
     7       
     8        def compute_file(self,input,output):
     9                filetask = self.task(input,params=self.params)
     10                computed_data = filetask.compute_all()
     11                results = filetask.eval(computed_data)
     12                self.results.append(results)
     13                truth = filetask.gettruth()
     14                #print input, results, results - float(input.split('.')[-2])
     15                self.pretty_print((self.params.mode, truth,
     16                        truth - results[0], results[0],
     17                        truth - results[1], results[1]))
     18                       
     19        def compute_data(self):
     20                self.orig, self.missed, self.merged, self.expc, \
     21                        self.bad, self.doubled = 0, 0, 0, 0, 0, 0
     22                act_on_data(self.compute_file,self.datadir, \
     23                        suffix='',filter='f -name \'*.wav\'')
     24       
     25        def compute_results(self,truth):
     26                for i in self.results: print i
    1027
    11 MODES = 'yin', 'mcomb', 'fcomb', 'schmitt'
     28        def run_bench(self,modes=['dual']):
     29                self.modes = modes
     30                self.pretty_print(self.titles)
     31                for mode in self.modes:
     32                        self.params.mode = mode
     33                        self.compute_data()
     34                        #self.compute_results()
     35                        #self.pretty_print(self.results)
    1236
    13 #        prepareresultpath
    14 act_on_results(mkdir,datapath,respath,filter='d')
     37if __name__ == "__main__":
     38        import sys
     39        if len(sys.argv) > 1: datapath = sys.argv[1]
     40        else: print "error: a path is required"; sys.exit(1)
    1541
    16 def compute_data(input,output):
    17         aubiocmd = "%s%s %s%s" % \
    18                 ("LD_LIBRARY_PATH=",LD_LIBRARY_PATH,AUBIOHOME,"/python/aubiopitch")
    19         for m in MODES:
    20                 cmd = "%s --input \"%s\" --mode %s --verbose --units midi > \"%s--%s.txt\"" \
    21                         % (aubiocmd,input,m,output,m)
    22                 runcommand(cmd,debug=0)
     42        modes = ['schmitt', 'yin', 'mcomb', 'fcomb']
    2343
     44        benchpitch = benchpitch(datapath)
     45        benchpitch.params = taskparams()
     46        benchpitch.task = taskpitch
    2447
    25 #        computedata
    26 act_on_data(compute_data,datapath,respath,suffix='',filter='f -name \'*.wav\'')
     48        benchpitch.titles  = [ 'mode', 'thres', 'avg', 'avgdist' ]
     49        benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ]
     50        try:
     51                benchpitch.run_bench(modes=modes)
     52        except KeyboardInterrupt:
     53                print "Interrupted by user"
     54                sys.exit(1)
    2755
    28 #        gatherdata
    29 #act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'')
    30 #        gatherthreshold
    31 #        gathermodes
    32 #        comparediffs
    33 #        gatherdiffs
    34 
     56        sys.exit(0)
Note: See TracChangeset for help on using the changeset viewer.