def onButtonExport(self, event): # Create the progress bar then run the annotations wx.BeginBusyCursor() p = ProcessProgressDialog(self, self.preferences) p.set_title("Time Group Analysis...") p.set_header("Annotation generation") p.update(0,"") total = len(self._data.items()) i = 0 # Work: Generate TGA annotations for each of the given files for tg,filename in self._data.items(): p.set_text( filename ) # estimates TGA trs = tg.tga_as_transcription() # save as file infile, ext = os.path.splitext(filename) outfile = infile + "-tga" + ext logging.debug('Export file: %s'%outfile) annotationdata.io.write(outfile,trs) # uppdate progress bar i = i+1 p.set_fraction(float((i+1))/float(total)) # Close progress bar p.close() wx.EndBusyCursor()
def Run(self, parent, filelist, activeannot, parameters): """ Execute the automatic annotations. """ # Check input files if len(filelist) == 0: message = "Empty selection! Select audio file(s) to annotate." ShowInformation( None, self.preferences, message ) return # Fix options nbsteps = 0 for i in range(len(activeannot)): if activeannot[i]: nbsteps = nbsteps + 1 parameters.activate_step(i) #if there are languages available and none of them is selected, print an error if len(parameters.get_langlist(i)) > 0 and parameters.get_lang(i) == None: message = "There isn't any language selected for the annotation \"%s\"" % parameters.get_step_name(i) ShowInformation( None, self.preferences, message ) return else: parameters.disable_step(i) if not nbsteps: message = "No annotation selected! Check steps to annotate." ShowInformation( None, self.preferences, message ) return parameters.set_sppasinput(filelist) parameters.set_output_format(self.preferences.GetValue('M_OUTPUT_EXT')) # Create the progress bar then run the annotations wx.BeginBusyCursor() p = ProcessProgressDialog(parent, self.preferences) p.set_title("Automatic Annotation progress...") self.process = sppasProcess(parameters) self.process.run_annotations( p ) p.close() self.process = None wx.EndBusyCursor() # Show report try: ShowLogDialog(parent, self.preferences, parameters.get_logfilename()) except Exception as e: import logging #import traceback #print traceback.format_exc() logging.debug('Log Error: %s'%str(e)) message = "Automatic annotation finished.\nSee " + parameters.get_logfilename() + " for details.\nThanks for using SPPAS.\n" ShowInformation( None, self.preferences, message ) try: os.remove(parameters.get_logfilename()) # eg. source or destination doesn't exist except IOError, shutil.Error: pass
def RunRelationFilter(self, parent, tiername, annotformat): wx.BeginBusyCursor() # Create the progress bar p = ProcessProgressDialog(parent, parent._prefsIO) p.set_title("Filtering progress...") self._runRelationFilter(tiername, p, annotformat) p.close() wx.EndBusyCursor()