montreal_forced_aligner/alignment/mixins.py
def compile_train_graphs(self) -> None:
        """
        Multiprocessing function that compiles training graphs for utterances.

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.CompileTrainGraphsFunction`
            Multiprocessing helper function for each job
        :meth:`.AlignMixin.compile_train_graphs_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()
        log_directory = self.working_log_directory
        os.makedirs(log_directory, exist_ok=True)
        self.logger.info("Compiling training graphs...")
        error_sum = 0
        arguments = self.compile_train_graphs_arguments()
        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(arguments):
                    function = CompileTrainGraphsFunction(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)
                        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)
                    error_sum += errors
                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 arguments:
                    function = CompileTrainGraphsFunction(args)
                    for done, errors in function.run():
                        pbar.update(done + errors)
                        error_sum += errors
        if error_sum:
            self.logger.warning(
                f"Compilation of training graphs failed for {error_sum} utterances."
            )
        self.logger.debug(f"Compiling training graphs took {time.time() - begin}")

        Multiprocessing function that compiles training graphs for utterances.

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.CompileTrainGraphsFunction`
            Multiprocessing helper function for each job
        :meth:`.AlignMixin.compile_train_graphs_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 compiles training graphs for utterances.
See Also
Multiprocessing function that compiles training graphs for utterances . See Also
def compile_train_graphs(self) -> None:
        begin = time.time()
        log_directory = self.working_log_directory
        os.makedirs(log_directory, exist_ok=True)
        self.logger.info("Compiling training graphs...")
        error_sum = 0
        arguments = self.compile_train_graphs_arguments()
        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(arguments):
                    function = CompileTrainGraphsFunction(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)
                        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)
                    error_sum += errors
                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 arguments:
                    function = CompileTrainGraphsFunction(args)
                    for done, errors in function.run():
                        pbar.update(done + errors)
                        error_sum += errors
        if error_sum:
            self.logger.warning(
                f"Compilation of training graphs failed for {error_sum} utterances."
            )
        self.logger.debug(f"Compiling training graphs took {time.time() - begin}")
def compile_train_graphs ( self ) -> None : begin = time . time ( ) log_directory = self . working_log_directory os . makedirs ( log_directory , exist_ok = True ) self . logger . info ( "Compiling training graphs..." ) error_sum = 0 arguments = self . compile_train_graphs_arguments ( ) 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 ( arguments ) : function = CompileTrainGraphsFunction ( 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 ) 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 ) error_sum += errors 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 arguments : function = CompileTrainGraphsFunction ( args ) for done , errors in function . run ( ) : pbar . update ( done + errors ) error_sum += errors if error_sum : self . logger . warning ( f"Compilation of training graphs failed for {error_sum} utterances." ) self . logger . debug ( f"Compiling training graphs took {time.time() - begin}" )
Multiprocessing function that compiles training graphs for utterances.
Multiprocessing function that compiles training graphs for utterances .
"""
        Multiprocessing function that compiles training graphs for utterances.

        See Also
        --------
        :class:`~montreal_forced_aligner.alignment.multiprocessing.CompileTrainGraphsFunction`
            Multiprocessing helper function for each job
        :meth:`.AlignMixin.compile_train_graphs_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.CompileTrainGraphsFunction`
Multiprocessing helper function for each job
` ~montreal_forced_aligner . alignment . multiprocessing . CompileTrainGraphsFunction ` Multiprocessing helper function for each job
meth
`.AlignMixin.compile_train_graphs_arguments`
Job method for generating arguments for the helper function
` . AlignMixin . compile_train_graphs_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