montreal_forced_aligner/alignment/base.py
def ali_to_ctm(self, word_mode=True):
        """
        Convert alignment archives to CTM format

        Parameters
        ----------
        word_mode: bool
            Flag for generating word or phone CTMs

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.AliToCtmFunction`
            Multiprocessing function
        :meth:`.CorpusAligner.ali_to_word_ctm_arguments`
            Arguments for word CTMS
        :meth:`.CorpusAligner.ali_to_phone_ctm_arguments`
            Arguments for phone CTMS
        """
        if word_mode:
            self.logger.info("Generating word CTM files from alignment lattices...")
            jobs = self.ali_to_word_ctm_arguments()  # Word CTM jobs
        else:
            self.logger.info("Generating phone CTM files from alignment lattices...")
            jobs = self.ali_to_phone_ctm_arguments()  # Phone CTM jobs
        sum_errors = 0
        with tqdm.tqdm(total=self.num_utterances) as pbar:
            if self.use_mp:
                manager = mp.Manager()
                error_dict = manager.dict()
                return_queue = manager.Queue()
                stopped = Stopped()
                procs = []
                for i, args in enumerate(jobs):
                    function = AliToCtmFunction(args)
                    p = KaldiProcessWorker(i, return_queue, function, error_dict, stopped)
                    procs.append(p)
                    p.start()
                while True:
                    try:
                        done, errors = return_queue.get(timeout=1)
                        sum_errors += errors
                        if stopped.stop_check():
                            continue
                    except Empty:
                        for proc in procs:
                            if not proc.finished.stop_check():
                                break
                        else:
                            break
                        continue
                    pbar.update(done + errors)
                for p in procs:
                    p.join()
                if error_dict:
                    for v in error_dict.values():
                        raise v
            else:
                for args in jobs:
                    function = AliToCtmFunction(args)
                    for done, errors in function.run():
                        sum_errors += errors
                        pbar.update(done + errors)
            if sum_errors:
                self.logger.warning(f"{errors} utterances had errors during creating CTM files.")

        Convert alignment archives to CTM format

        Parameters
        ----------
        word_mode: bool
            Flag for generating word or phone CTMs

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.AliToCtmFunction`
            Multiprocessing function
        :meth:`.CorpusAligner.ali_to_word_ctm_arguments`
            Arguments for word CTMS
        :meth:`.CorpusAligner.ali_to_phone_ctm_arguments`
            Arguments for phone CTMS
        
Convert alignment archives to CTM format
Parameters

bool
Flag for generating word or phone CTMs

See Also
Convert alignment archives to CTM format Parameters bool Flag for generating word or phone CTMs See Also
def ali_to_ctm(self, word_mode=True):
        if word_mode:
            self.logger.info("Generating word CTM files from alignment lattices...")
            jobs = self.ali_to_word_ctm_arguments()  
        else:
            self.logger.info("Generating phone CTM files from alignment lattices...")
            jobs = self.ali_to_phone_ctm_arguments()  
        sum_errors = 0
        with tqdm.tqdm(total=self.num_utterances) as pbar:
            if self.use_mp:
                manager = mp.Manager()
                error_dict = manager.dict()
                return_queue = manager.Queue()
                stopped = Stopped()
                procs = []
                for i, args in enumerate(jobs):
                    function = AliToCtmFunction(args)
                    p = KaldiProcessWorker(i, return_queue, function, error_dict, stopped)
                    procs.append(p)
                    p.start()
                while True:
                    try:
                        done, errors = return_queue.get(timeout=1)
                        sum_errors += errors
                        if stopped.stop_check():
                            continue
                    except Empty:
                        for proc in procs:
                            if not proc.finished.stop_check():
                                break
                        else:
                            break
                        continue
                    pbar.update(done + errors)
                for p in procs:
                    p.join()
                if error_dict:
                    for v in error_dict.values():
                        raise v
            else:
                for args in jobs:
                    function = AliToCtmFunction(args)
                    for done, errors in function.run():
                        sum_errors += errors
                        pbar.update(done + errors)
            if sum_errors:
                self.logger.warning(f"{errors} utterances had errors during creating CTM files.")
def ali_to_ctm ( self , word_mode = True ) : if word_mode : self . logger . info ( "Generating word CTM files from alignment lattices..." ) jobs = self . ali_to_word_ctm_arguments ( ) else : self . logger . info ( "Generating phone CTM files from alignment lattices..." ) jobs = self . ali_to_phone_ctm_arguments ( ) sum_errors = 0 with tqdm . tqdm ( total = self . num_utterances ) as pbar : if self . use_mp : manager = mp . Manager ( ) error_dict = manager . dict ( ) return_queue = manager . Queue ( ) stopped = Stopped ( ) procs = [ ] for i , args in enumerate ( jobs ) : function = AliToCtmFunction ( args ) p = KaldiProcessWorker ( i , return_queue , function , error_dict , stopped ) procs . append ( p ) p . start ( ) while True : try : done , errors = return_queue . get ( timeout = 1 ) sum_errors += errors if stopped . stop_check ( ) : continue except Empty : for proc in procs : if not proc . finished . stop_check ( ) : break else : break continue pbar . update ( done + errors ) for p in procs : p . join ( ) if error_dict : for v in error_dict . values ( ) : raise v else : for args in jobs : function = AliToCtmFunction ( args ) for done , errors in function . run ( ) : sum_errors += errors pbar . update ( done + errors ) if sum_errors : self . logger . warning ( f"{errors} utterances had errors during creating CTM files." )
Convert alignment archives to CTM format
Parameters
Convert alignment archives to CTM format Parameters
"""
        Convert alignment archives to CTM format

        Parameters
        ----------
        word_mode: bool
            Flag for generating word or phone CTMs

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.AliToCtmFunction`
            Multiprocessing function
        :meth:`.CorpusAligner.ali_to_word_ctm_arguments`
            Arguments for word CTMS
        :meth:`.CorpusAligner.ali_to_phone_ctm_arguments`
            Arguments for phone CTMS
        """ # Word CTM jobs # Phone CTM jobs
self
word_mode
class
`~montreal_forced_aligner.alignment.multiprocessing.AliToCtmFunction`
Multiprocessing function
` ~montreal_forced_aligner . alignment . multiprocessing . AliToCtmFunction ` Multiprocessing function
meth
`.CorpusAligner.ali_to_word_ctm_arguments`
Arguments for word CTMS
` . CorpusAligner . ali_to_word_ctm_arguments ` Arguments for word CTMS
meth
`.CorpusAligner.ali_to_phone_ctm_arguments`
Arguments for phone CTMS
` . CorpusAligner . ali_to_phone_ctm_arguments ` Arguments for phone CTMS