montreal_forced_aligner/corpus/acoustic_corpus.py
def construct_feature_proc_strings(
        self,
        speaker_independent: bool = False,
    ) -> List[Dict[str, str]]:
        """
        Constructs a feature processing string to supply to Kaldi binaries, taking into account corpus features and the
        current working directory of the aligner (whether fMLLR or LDA transforms should be used, etc).

        Parameters
        ----------
        speaker_independent: bool
            Flag for whether features should be speaker-independent regardless of the presence of fMLLR transforms

        Returns
        -------
        list[dict[str, str]]
            Feature strings per job
        """
        strings = []
        for j in self.jobs:
            lda_mat_path = None
            fmllrs = {}
            if self.working_directory is not None:
                lda_mat_path = os.path.join(self.working_directory, "lda.mat")
                if not os.path.exists(lda_mat_path):
                    lda_mat_path = None

                fmllrs = j.construct_path_dictionary(self.working_directory, "trans", "ark")
            utt2spks = j.construct_path_dictionary(self.data_directory, "utt2spk", "scp")
            cmvns = j.construct_path_dictionary(self.data_directory, "cmvn", "scp")
            features = j.construct_path_dictionary(self.data_directory, "feats", "scp")
            vads = j.construct_path_dictionary(self.data_directory, "vad", "scp")
            feat_strings = {}
            for dict_name in j.current_dictionary_names:
                feat_path = features[dict_name]
                cmvn_path = cmvns[dict_name]
                utt2spk_path = utt2spks[dict_name]
                fmllr_trans_path = None
                try:
                    fmllr_trans_path = fmllrs[dict_name]
                    if not os.path.exists(fmllr_trans_path):
                        fmllr_trans_path = None
                except KeyError:
                    pass
                vad_path = vads[dict_name]
                if self.uses_voiced:
                    feats = f"ark,s,cs:add-deltas scp:{feat_path} ark:- |"
                    if self.uses_cmvn:
                        feats += " apply-cmvn-sliding --norm-vars=false --center=true --cmn-window=300 ark:- ark:- |"
                    feats += f" select-voiced-frames ark:- scp,s,cs:{vad_path} ark:- |"
                elif not os.path.exists(cmvn_path) and self.uses_cmvn:
                    feats = f"ark,s,cs:add-deltas scp:{feat_path} ark:- |"
                    if self.uses_cmvn:
                        feats += " apply-cmvn-sliding --norm-vars=false --center=true --cmn-window=300 ark:- ark:- |"
                else:
                    feats = f"ark,s,cs:apply-cmvn --utt2spk=ark:{utt2spk_path} scp:{cmvn_path} scp:{feat_path} ark:- |"
                    if lda_mat_path is not None:
                        if not os.path.exists(lda_mat_path):
                            raise Exception(f"Could not find {lda_mat_path}")
                        feats += f" splice-feats --left-context={self.splice_left_context} --right-context={self.splice_right_context} ark:- ark:- |"
                        feats += f" transform-feats {lda_mat_path} ark:- ark:- |"
                    elif self.uses_splices:
                        feats += f" splice-feats --left-context={self.splice_left_context} --right-context={self.splice_right_context} ark:- ark:- |"
                    elif self.uses_deltas:
                        feats += " add-deltas ark:- ark:- |"

                    if fmllr_trans_path is not None and not (
                        self.speaker_independent or speaker_independent
                    ):
                        if not os.path.exists(fmllr_trans_path):
                            raise Exception(f"Could not find {fmllr_trans_path}")
                        feats += f" transform-feats --utt2spk=ark:{utt2spk_path} ark:{fmllr_trans_path} ark:- ark:- |"
                feat_strings[dict_name] = feats
            strings.append(feat_strings)
        return strings

        Constructs a feature processing string to supply to Kaldi binaries, taking into account corpus features and the
        current working directory of the aligner (whether fMLLR or LDA transforms should be used, etc).

        Parameters
        ----------
        speaker_independent: bool
            Flag for whether features should be speaker-independent regardless of the presence of fMLLR transforms

        Returns
        -------
        list[dict[str, str]]
            Feature strings per job
        
Constructs a feature processing string to supply to Kaldi binaries, taking into account corpus features and the
current working directory of the aligner (whether fMLLR or LDA transforms should be used, etc).

Parameters

bool
Flag for whether features should be speaker-independent regardless of the presence of fMLLR transforms

Returns

list[dict[str, str]]
Feature strings per job
Constructs a feature processing string to supply to Kaldi binaries taking into account corpus features and the current working directory of the aligner ( whether fMLLR or LDA transforms should be used etc ) . Parameters bool Flag for whether features should be speaker - independent regardless of the presence of fMLLR transforms Returns list [ dict [ str str ]] Feature strings per job
def construct_feature_proc_strings(
        self,
        speaker_independent: bool = False,
    ) -> List[Dict[str, str]]:
        strings = []
        for j in self.jobs:
            lda_mat_path = None
            fmllrs = {}
            if self.working_directory is not None:
                lda_mat_path = os.path.join(self.working_directory, "lda.mat")
                if not os.path.exists(lda_mat_path):
                    lda_mat_path = None
                fmllrs = j.construct_path_dictionary(self.working_directory, "trans", "ark")
            utt2spks = j.construct_path_dictionary(self.data_directory, "utt2spk", "scp")
            cmvns = j.construct_path_dictionary(self.data_directory, "cmvn", "scp")
            features = j.construct_path_dictionary(self.data_directory, "feats", "scp")
            vads = j.construct_path_dictionary(self.data_directory, "vad", "scp")
            feat_strings = {}
            for dict_name in j.current_dictionary_names:
                feat_path = features[dict_name]
                cmvn_path = cmvns[dict_name]
                utt2spk_path = utt2spks[dict_name]
                fmllr_trans_path = None
                try:
                    fmllr_trans_path = fmllrs[dict_name]
                    if not os.path.exists(fmllr_trans_path):
                        fmllr_trans_path = None
                except KeyError:
                    pass
                vad_path = vads[dict_name]
                if self.uses_voiced:
                    feats = f"ark,s,cs:add-deltas scp:{feat_path} ark:- |"
                    if self.uses_cmvn:
                        feats += " apply-cmvn-sliding --norm-vars=false --center=true --cmn-window=300 ark:- ark:- |"
                    feats += f" select-voiced-frames ark:- scp,s,cs:{vad_path} ark:- |"
                elif not os.path.exists(cmvn_path) and self.uses_cmvn:
                    feats = f"ark,s,cs:add-deltas scp:{feat_path} ark:- |"
                    if self.uses_cmvn:
                        feats += " apply-cmvn-sliding --norm-vars=false --center=true --cmn-window=300 ark:- ark:- |"
                else:
                    feats = f"ark,s,cs:apply-cmvn --utt2spk=ark:{utt2spk_path} scp:{cmvn_path} scp:{feat_path} ark:- |"
                    if lda_mat_path is not None:
                        if not os.path.exists(lda_mat_path):
                            raise Exception(f"Could not find {lda_mat_path}")
                        feats += f" splice-feats --left-context={self.splice_left_context} --right-context={self.splice_right_context} ark:- ark:- |"
                        feats += f" transform-feats {lda_mat_path} ark:- ark:- |"
                    elif self.uses_splices:
                        feats += f" splice-feats --left-context={self.splice_left_context} --right-context={self.splice_right_context} ark:- ark:- |"
                    elif self.uses_deltas:
                        feats += " add-deltas ark:- ark:- |"
                    if fmllr_trans_path is not None and not (
                        self.speaker_independent or speaker_independent
                    ):
                        if not os.path.exists(fmllr_trans_path):
                            raise Exception(f"Could not find {fmllr_trans_path}")
                        feats += f" transform-feats --utt2spk=ark:{utt2spk_path} ark:{fmllr_trans_path} ark:- ark:- |"
                feat_strings[dict_name] = feats
            strings.append(feat_strings)
        return strings
def construct_feature_proc_strings ( self , speaker_independent : bool = False , ) -> List [ Dict [ str , str ] ] : strings = [ ] for j in self . jobs : lda_mat_path = None fmllrs = { } if self . working_directory is not None : lda_mat_path = os . path . join ( self . working_directory , "lda.mat" ) if not os . path . exists ( lda_mat_path ) : lda_mat_path = None fmllrs = j . construct_path_dictionary ( self . working_directory , "trans" , "ark" ) utt2spks = j . construct_path_dictionary ( self . data_directory , "utt2spk" , "scp" ) cmvns = j . construct_path_dictionary ( self . data_directory , "cmvn" , "scp" ) features = j . construct_path_dictionary ( self . data_directory , "feats" , "scp" ) vads = j . construct_path_dictionary ( self . data_directory , "vad" , "scp" ) feat_strings = { } for dict_name in j . current_dictionary_names : feat_path = features [ dict_name ] cmvn_path = cmvns [ dict_name ] utt2spk_path = utt2spks [ dict_name ] fmllr_trans_path = None try : fmllr_trans_path = fmllrs [ dict_name ] if not os . path . exists ( fmllr_trans_path ) : fmllr_trans_path = None except KeyError : pass vad_path = vads [ dict_name ] if self . uses_voiced : feats = f"ark,s,cs:add-deltas scp:{feat_path} ark:- |" if self . uses_cmvn : feats += " apply-cmvn-sliding --norm-vars=false --center=true --cmn-window=300 ark:- ark:- |" feats += f" select-voiced-frames ark:- scp,s,cs:{vad_path} ark:- |" elif not os . path . exists ( cmvn_path ) and self . uses_cmvn : feats = f"ark,s,cs:add-deltas scp:{feat_path} ark:- |" if self . uses_cmvn : feats += " apply-cmvn-sliding --norm-vars=false --center=true --cmn-window=300 ark:- ark:- |" else : feats = f"ark,s,cs:apply-cmvn --utt2spk=ark:{utt2spk_path} scp:{cmvn_path} scp:{feat_path} ark:- |" if lda_mat_path is not None : if not os . path . exists ( lda_mat_path ) : raise Exception ( f"Could not find {lda_mat_path}" ) feats += f" splice-feats --left-context={self.splice_left_context} --right-context={self.splice_right_context} ark:- ark:- |" feats += f" transform-feats {lda_mat_path} ark:- ark:- |" elif self . uses_splices : feats += f" splice-feats --left-context={self.splice_left_context} --right-context={self.splice_right_context} ark:- ark:- |" elif self . uses_deltas : feats += " add-deltas ark:- ark:- |" if fmllr_trans_path is not None and not ( self . speaker_independent or speaker_independent ) : if not os . path . exists ( fmllr_trans_path ) : raise Exception ( f"Could not find {fmllr_trans_path}" ) feats += f" transform-feats --utt2spk=ark:{utt2spk_path} ark:{fmllr_trans_path} ark:- ark:- |" feat_strings [ dict_name ] = feats strings . append ( feat_strings ) return strings
Constructs a feature processing string to supply to Kaldi binaries, taking into account corpus features and the
current working directory of the aligner (whether fMLLR or LDA transforms should be used, etc).
Constructs a feature processing string to supply to Kaldi binaries taking into account corpus features and the current working directory of the aligner ( whether fMLLR or LDA transforms should be used etc ) .
"""
        Constructs a feature processing string to supply to Kaldi binaries, taking into account corpus features and the
        current working directory of the aligner (whether fMLLR or LDA transforms should be used, etc).

        Parameters
        ----------
        speaker_independent: bool
            Flag for whether features should be speaker-independent regardless of the presence of fMLLR transforms

        Returns
        -------
        list[dict[str, str]]
            Feature strings per job
        """
self
speaker_independent
bool