def run_momel(self, stepidx): """ Execute the SPPAS implementation of momel. @param stepidx index of this annotations in the parameters @return number of files processed successfully """ # Initializations step = self.parameters.get_step(stepidx) stepname = self.parameters.get_step_name(stepidx) files_processed_success = 0 self._progress.set_header(stepname) self._progress.update(0,"") # Get the list of input file names, with the ".wav" (or ".wave") extension filelist = self.set_filelist(".wav")#,not_start=["track_"]) if len(filelist) == 0: return 0 total = len(filelist) # Create annotation instance try: m = sppasMomel( self._logfile ) except Exception as e: if self._logfile is not None: self._logfile.print_message( "%s\n"%str(e), indent=1,status=1 ) return 0 # Execute annotation for each file in the list for i,f in enumerate(filelist): # fix the default values m.fix_options( step.get_options() ) # Indicate the file to be processed self._progress.set_text( os.path.basename(f)+" ("+str(i+1)+"/"+str(total)+")" ) if self._logfile is not None: self._logfile.print_message(stepname+" of file " + f, indent=1 ) # Get the input file inname = self._get_filename(f, [".hz", ".PitchTier"]) if inname is not None: # Fix output file names outname = os.path.splitext(f)[0]+"-momel.PitchTier" textgridoutname = os.path.splitext(f)[0] + '-momel' + self.parameters.get_output_format() # Execute annotation try: m.run(inname, trsoutput=textgridoutname, outputfile=outname) files_processed_success += 1 if self._logfile is not None: self._logfile.print_message(textgridoutname,indent=2,status=0) except Exception as e: if self._logfile is not None: self._logfile.print_message(textgridoutname+": %s"%str(e),indent=2,status=-1) else: if self._logfile is not None: self._logfile.print_message("Failed to find a file with pitch values. Read the documentation for details.",indent=2,status=2) # Indicate progress self._progress.set_fraction(float((i+1))/float(total)) if self._logfile is not None: self._logfile.print_newline() # Indicate completed! self._progress.update(1,"Completed (%d files successfully over %d files).\n"%(files_processed_success,total)) self._progress.set_header("") return files_processed_success
parser.add_argument("--win2", type=int, default=20, help="Reduct window length (default: 20)") parser.add_argument("--mind", type=int, default=5, help="Minimal distance (default: 5)") parser.add_argument("--minr", type=float, default=0.05, help="Minimal frequency ratio (default: 0.05)") parser.add_argument("--non-elim-glitch", dest="nonglitch", action='store_true' ) if len(sys.argv) <= 1: sys.argv.append('-h') args = parser.parse_args() # ------------------------------------------------------------------------ # Momel and INTSINT are here # ------------------------------------------------------------------------ melodie = sppasMomel() if args.win1: melodie.momel.set_option_win1( args.win1 ) if args.lo: melodie.momel.set_option_lo( args.lo ) if args.hi: melodie.momel.set_option_hi( args.hi ) if args.maxerr: melodie.momel.set_option_maxerr( args.maxerr ) if args.win2: melodie.momel.set_option_win2( args.win2 ) if args.mind: melodie.momel.set_option_mind( args.mind ) if args.minr: melodie.momel.set_option_minr( args.minr ) if args.nonglitch: melodie.momel.set_option_elim_glitch(False) melodie.run(args.i, args.o, outputfile=None) if args.O: intsint = sppasIntsint() intsint.run( args.o, args.O )