montreal_forced_aligner/alignment/mixins.py
def align_utterances(self) -> None:
        """
        Multiprocessing function that aligns based on the current model.

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.AlignFunction`
            Multiprocessing helper function for each job
        :meth:`.AlignMixin.align_arguments`
            Job method for generating arguments for the helper function
        :kaldi_steps:`align_si`
            Reference Kaldi script
        :kaldi_steps:`align_fmllr`
            Reference Kaldi script
        """
        begin = time.time()
        self.unaligned_files = set()
        self.logger.info("Generating alignments...")
        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(self.align_arguments()):
                    function = AlignFunction(args)
                    p = KaldiProcessWorker(i, return_queue, function, error_dict, stopped)
                    procs.append(p)
                    p.start()
                while True:
                    try:
                        utterance, succeeded = return_queue.get(timeout=1)
                        if stopped.stop_check():
                            continue
                    except Empty:
                        for proc in procs:
                            if not proc.finished.stop_check():
                                break
                        else:
                            break
                        continue
                    if not succeeded and hasattr(self, "utterances"):
                        self.utterances[utterance].phone_labels = []
                        self.utterances[utterance].word_labels = []
                    else:
                        pbar.update(1)
                for p in procs:
                    p.join()
                if error_dict:
                    for v in error_dict.values():
                        raise v
            else:
                self.logger.debug("Not using multiprocessing...")
                for args in self.align_arguments():
                    function = AlignFunction(args)
                    for utterance, succeeded in function.run():
                        if not succeeded and hasattr(self, "utterances"):
                            self.utterances[utterance].phone_labels = []
                            self.utterances[utterance].word_labels = []
                        else:
                            pbar.update(1)

        self.compile_information()
        self.logger.debug(f"Alignment round took {time.time() - begin}")

        Multiprocessing function that aligns based on the current model.

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.AlignFunction`
            Multiprocessing helper function for each job
        :meth:`.AlignMixin.align_arguments`
            Job method for generating arguments for the helper function
        :kaldi_steps:`align_si`
            Reference Kaldi script
        :kaldi_steps:`align_fmllr`
            Reference Kaldi script
        
Multiprocessing function that aligns based on the current model.
See Also
Multiprocessing function that aligns based on the current model . See Also
def align_utterances(self) -> None:
        begin = time.time()
        self.unaligned_files = set()
        self.logger.info("Generating alignments...")
        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(self.align_arguments()):
                    function = AlignFunction(args)
                    p = KaldiProcessWorker(i, return_queue, function, error_dict, stopped)
                    procs.append(p)
                    p.start()
                while True:
                    try:
                        utterance, succeeded = return_queue.get(timeout=1)
                        if stopped.stop_check():
                            continue
                    except Empty:
                        for proc in procs:
                            if not proc.finished.stop_check():
                                break
                        else:
                            break
                        continue
                    if not succeeded and hasattr(self, "utterances"):
                        self.utterances[utterance].phone_labels = []
                        self.utterances[utterance].word_labels = []
                    else:
                        pbar.update(1)
                for p in procs:
                    p.join()
                if error_dict:
                    for v in error_dict.values():
                        raise v
            else:
                self.logger.debug("Not using multiprocessing...")
                for args in self.align_arguments():
                    function = AlignFunction(args)
                    for utterance, succeeded in function.run():
                        if not succeeded and hasattr(self, "utterances"):
                            self.utterances[utterance].phone_labels = []
                            self.utterances[utterance].word_labels = []
                        else:
                            pbar.update(1)
        self.compile_information()
        self.logger.debug(f"Alignment round took {time.time() - begin}")
def align_utterances ( self ) -> None : begin = time . time ( ) self . unaligned_files = set ( ) self . logger . info ( "Generating alignments..." ) 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 ( self . align_arguments ( ) ) : function = AlignFunction ( args ) p = KaldiProcessWorker ( i , return_queue , function , error_dict , stopped ) procs . append ( p ) p . start ( ) while True : try : utterance , succeeded = return_queue . get ( timeout = 1 ) if stopped . stop_check ( ) : continue except Empty : for proc in procs : if not proc . finished . stop_check ( ) : break else : break continue if not succeeded and hasattr ( self , "utterances" ) : self . utterances [ utterance ] . phone_labels = [ ] self . utterances [ utterance ] . word_labels = [ ] else : pbar . update ( 1 ) for p in procs : p . join ( ) if error_dict : for v in error_dict . values ( ) : raise v else : self . logger . debug ( "Not using multiprocessing..." ) for args in self . align_arguments ( ) : function = AlignFunction ( args ) for utterance , succeeded in function . run ( ) : if not succeeded and hasattr ( self , "utterances" ) : self . utterances [ utterance ] . phone_labels = [ ] self . utterances [ utterance ] . word_labels = [ ] else : pbar . update ( 1 ) self . compile_information ( ) self . logger . debug ( f"Alignment round took {time.time() - begin}" )
Multiprocessing function that aligns based on the current model.
Multiprocessing function that aligns based on the current model .
"""
        Multiprocessing function that aligns based on the current model.

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.AlignFunction`
            Multiprocessing helper function for each job
        :meth:`.AlignMixin.align_arguments`
            Job method for generating arguments for the helper function
        :kaldi_steps:`align_si`
            Reference Kaldi script
        :kaldi_steps:`align_fmllr`
            Reference Kaldi script
        """
self
class
`~montreal_forced_aligner.alignment.multiprocessing.AlignFunction`
Multiprocessing helper function for each job
` ~montreal_forced_aligner . alignment . multiprocessing . AlignFunction ` Multiprocessing helper function for each job
meth
`.AlignMixin.align_arguments`
Job method for generating arguments for the helper function
` . AlignMixin . align_arguments ` Job method for generating arguments for the helper function
kaldi_steps
`align_si`
Reference Kaldi script
` align_si ` Reference Kaldi script
kaldi_steps
`align_fmllr`
Reference Kaldi script
` align_fmllr ` Reference Kaldi script