def run_intsint(self, stepidx): """ Execute the SPPAS implementation of Intsint. @param stepidx index of this annotations in the parameters @return number of files processed successfully """ # Initializations 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: intsint = sppasIntsint( 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): # 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 ext = ['-momel'+self.parameters.get_output_format()] for e in annotationdata.io.extensions_out: ext.append( '-momel'+e ) inname = self._get_filename(f, ext) if inname is not None: # Fix output file names outname = os.path.splitext(f)[0] + '-intsint' + self.parameters.get_output_format() # Execute annotation try: intsint.run(inname, outname) files_processed_success += 1 if self._logfile is not None: self._logfile.print_message(outname,indent=2,status=0) except Exception as e: if self._logfile is not None: self._logfile.print_message(outname+": %s"%str(e),indent=2,status=-1) else: if self._logfile is not None: self._logfile.print_message("Failed to find a file with momel targets. 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("--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 ) # ----------------------------------------------------------------------------