Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    print term.render('${BLUE}'+url+'${NORMAL}')
    print term.render('${GREEN}-----------------------------------------------------------------------${NORMAL}\n')
except:
    print '-----------------------------------------------------------------------\n'
    print program+'   -  Version '+version
    print copyright
    print url+'\n'
    print '-----------------------------------------------------------------------\n'


# ----------------------------------------------------------------------------
# Annotation is here
# ----------------------------------------------------------------------------

p = TextProgress()
process = sppasProcess( parameters )
if args.nomerge:
    process.set_domerge( False )
if args.merge:
    process.set_domerge( True )
process.run_annotations( p )

try:
    term = TerminalController()
    print term.render('${GREEN}-----------------------------------------------------------------------${NORMAL}')
    print term.render('${RED}See '+parameters.get_logfilename()+' for details.')
    print term.render('${GREEN}Thank you for using '+program+".")
    print term.render('${GREEN}-----------------------------------------------------------------------${NORMAL}\n')
except:
    print ('-----------------------------------------------------------------------\n')
    print "See "+parameters.get_logfilename()+" for details.\nThank you for using "+program+"."