montreal_forced_aligner/alignment/base.py
def ctms_to_textgrids_non_mp(self) -> None:
        """
        Parse CTM files to TextGrids without using multiprocessing
        """
        self.log_debug("Not using multiprocessing for TextGrid export")
        export_errors = {}
        w_args = self.word_ctm_arguments()
        p_args = self.phone_ctm_arguments()
        for j in self.jobs:

            word_arguments = w_args[j.name]
            phone_arguments = p_args[j.name]
            self.logger.debug(f"Parsing ctms for job {j.name}...")

            for dict_name in word_arguments.dictionaries:
                with open(word_arguments.ctm_paths[dict_name], "r") as f:
                    for line in f:
                        line = line.strip()
                        if line == "":
                            continue
                        interval = process_ctm_line(line)
                        utt = self.utterances[interval.utterance]
                        dictionary = self.get_dictionary(utt.speaker_name)
                        label = dictionary.reversed_word_mapping[int(interval.label)]

                        interval.label = label
                        utt.add_word_intervals(interval)

            for dict_name in phone_arguments.dictionaries:
                with open(phone_arguments.ctm_paths[dict_name], "r") as f:
                    for line in f:
                        line = line.strip()
                        if line == "":
                            continue
                        interval = process_ctm_line(line)
                        utt = self.utterances[interval.utterance]
                        dictionary = self.get_dictionary(utt.speaker_name)

                        label = dictionary.reversed_phone_mapping[int(interval.label)]
                        if self.position_dependent_phones:
                            for p in dictionary.positions:
                                if label.endswith(p):
                                    label = label[: -1 * len(p)]
                        interval.label = label
                        utt.add_phone_intervals(interval)
        for file in self.files:
            data = file.aligned_data

            backup_output_directory = None
            if not self.overwrite:
                backup_output_directory = self.backup_output_directory
                os.makedirs(backup_output_directory, exist_ok=True)
            output_path = file.construct_output_path(self.textgrid_output, backup_output_directory)
            export_textgrid(data, output_path, file.duration, self.frame_shift)

        if export_errors:
            self.logger.warning(
                f"There were {len(export_errors)} errors encountered in generating TextGrids. "
                f"Check the output_errors.txt file in {os.path.join(self.textgrid_output)} "
                f"for more details"
            )
        output_textgrid_writing_errors(self.textgrid_output, export_errors)

        Parse CTM files to TextGrids without using multiprocessing
        
Parse CTM files to TextGrids without using multiprocessing
Parse CTM files to TextGrids without using multiprocessing
def ctms_to_textgrids_non_mp(self) -> None:
        self.log_debug("Not using multiprocessing for TextGrid export")
        export_errors = {}
        w_args = self.word_ctm_arguments()
        p_args = self.phone_ctm_arguments()
        for j in self.jobs:
            word_arguments = w_args[j.name]
            phone_arguments = p_args[j.name]
            self.logger.debug(f"Parsing ctms for job {j.name}...")
            for dict_name in word_arguments.dictionaries:
                with open(word_arguments.ctm_paths[dict_name], "r") as f:
                    for line in f:
                        line = line.strip()
                        if line == "":
                            continue
                        interval = process_ctm_line(line)
                        utt = self.utterances[interval.utterance]
                        dictionary = self.get_dictionary(utt.speaker_name)
                        label = dictionary.reversed_word_mapping[int(interval.label)]
                        interval.label = label
                        utt.add_word_intervals(interval)
            for dict_name in phone_arguments.dictionaries:
                with open(phone_arguments.ctm_paths[dict_name], "r") as f:
                    for line in f:
                        line = line.strip()
                        if line == "":
                            continue
                        interval = process_ctm_line(line)
                        utt = self.utterances[interval.utterance]
                        dictionary = self.get_dictionary(utt.speaker_name)
                        label = dictionary.reversed_phone_mapping[int(interval.label)]
                        if self.position_dependent_phones:
                            for p in dictionary.positions:
                                if label.endswith(p):
                                    label = label[: -1 * len(p)]
                        interval.label = label
                        utt.add_phone_intervals(interval)
        for file in self.files:
            data = file.aligned_data
            backup_output_directory = None
            if not self.overwrite:
                backup_output_directory = self.backup_output_directory
                os.makedirs(backup_output_directory, exist_ok=True)
            output_path = file.construct_output_path(self.textgrid_output, backup_output_directory)
            export_textgrid(data, output_path, file.duration, self.frame_shift)
        if export_errors:
            self.logger.warning(
                f"There were {len(export_errors)} errors encountered in generating TextGrids. "
                f"Check the output_errors.txt file in {os.path.join(self.textgrid_output)} "
                f"for more details"
            )
        output_textgrid_writing_errors(self.textgrid_output, export_errors)
def ctms_to_textgrids_non_mp ( self ) -> None : self . log_debug ( "Not using multiprocessing for TextGrid export" ) export_errors = { } w_args = self . word_ctm_arguments ( ) p_args = self . phone_ctm_arguments ( ) for j in self . jobs : word_arguments = w_args [ j . name ] phone_arguments = p_args [ j . name ] self . logger . debug ( f"Parsing ctms for job {j.name}..." ) for dict_name in word_arguments . dictionaries : with open ( word_arguments . ctm_paths [ dict_name ] , "r" ) as f : for line in f : line = line . strip ( ) if line == "" : continue interval = process_ctm_line ( line ) utt = self . utterances [ interval . utterance ] dictionary = self . get_dictionary ( utt . speaker_name ) label = dictionary . reversed_word_mapping [ int ( interval . label ) ] interval . label = label utt . add_word_intervals ( interval ) for dict_name in phone_arguments . dictionaries : with open ( phone_arguments . ctm_paths [ dict_name ] , "r" ) as f : for line in f : line = line . strip ( ) if line == "" : continue interval = process_ctm_line ( line ) utt = self . utterances [ interval . utterance ] dictionary = self . get_dictionary ( utt . speaker_name ) label = dictionary . reversed_phone_mapping [ int ( interval . label ) ] if self . position_dependent_phones : for p in dictionary . positions : if label . endswith ( p ) : label = label [ : - 1 * len ( p ) ] interval . label = label utt . add_phone_intervals ( interval ) for file in self . files : data = file . aligned_data backup_output_directory = None if not self . overwrite : backup_output_directory = self . backup_output_directory os . makedirs ( backup_output_directory , exist_ok = True ) output_path = file . construct_output_path ( self . textgrid_output , backup_output_directory ) export_textgrid ( data , output_path , file . duration , self . frame_shift ) if export_errors : self . logger . warning ( f"There were {len(export_errors)} errors encountered in generating TextGrids. " f"Check the output_errors.txt file in {os.path.join(self.textgrid_output)} " f"for more details" ) output_textgrid_writing_errors ( self . textgrid_output , export_errors )
Parse CTM files to TextGrids without using multiprocessing
Parse CTM files to TextGrids without using multiprocessing
"""
        Parse CTM files to TextGrids without using multiprocessing
        """
self