MultispeakerDictionaryMixin#

class montreal_forced_aligner.dictionary.multispeaker.MultispeakerDictionaryMixin(dictionary_path=None, rules_path=None, phone_groups_path=None, **kwargs)[source]#

Bases: TemporaryDictionaryMixin

Mixin class containing information about a pronunciation dictionary with different dictionaries per speaker

Parameters:
  • dictionary_path (str) – Dictionary path

  • kwargs (kwargs) – Extra parameters to passed to parent classes (see below)

See also

DictionaryMixin

For dictionary parsing parameters

TemporaryDirectoryMixin

For temporary directory parameters

Variables:
  • dictionary_model (DictionaryModel) – Dictionary model

  • dictionary_lookup (dict[str, int]) – Mapping of dictionary names to ids

add_words(new_word_data, dictionary_id=None)[source]#

Add word data to a dictionary in the form exported from words_for_export

Parameters:
  • new_word_data (list[dict[str,Any]]) – Word data to add

  • dictionary_id (int, optional) – Dictionary id to add words, defaults to the default dictionary

apply_phonological_rules()[source]#

Apply any phonological rules specified in the rules file path

calculate_disambiguation()[source]#

Calculate the number of disambiguation symbols necessary for the dictionary

calculate_phone_mapping()[source]#

Calculate the necessary phones and add phone objects to the database

property dictionary_base_names#

Mapping of base file names for pronunciation dictionaries

dictionary_setup()[source]#

Set up the dictionary for processing

export_lexicon(dictionary_id, path, write_disambiguation=False, probability=False)[source]#

Export pronunciation dictionary to a text file

Parameters:
  • path (Path) – Path to save dictionary

  • write_disambiguation (bool, optional) – Flag for whether to include disambiguation information

  • probability (bool, optional) – Flag for whether to include probabilities

export_trained_rules(output_directory)[source]#

Export rules with pronunciation and silence probabilities calculated to an output directory

Parameters:

output_directory (str) – Directory for export

find_all_cutoffs()[source]#

Find all instances of cutoff words followed by actual words

get_dict_id_for_speaker(speaker_name)[source]#

Get the dictionary id of the speaker

Parameters:

speaker_name (str) – Speaker to look up

Returns:

Dictionary id

Return type:

int

property grapheme_mapping#

Mapping of phone symbols to integer IDs for Kaldi processing

load_phone_groups()[source]#

Load phone groups from the dictionary’s groups file path

property name#

Name of the dictionary

property num_dictionaries#

Number of pronunciation dictionaries

property phone_disambig_path#

Path to file containing phone symbols and their integer IDs

property phone_mapping#

Mapping of phone symbols to integer IDs for Kaldi processing

property phone_table#

Mapping of phone symbols to integer IDs for Kaldi processing

property reversed_grapheme_mapping#

A mapping of integer ids to graphemes

reversed_word_mapping(dictionary_id=1)[source]#

Get the reversed word mapping for a specified dictionary id

Parameters:

dictionary_id (int, optional) – Database ID for dictionary, defaults to 1

Returns:

Mapping from integer IDs to words for Kaldi processing

Return type:

dict[int, str]

save_oovs_found(directory)[source]#

Save all out of vocabulary items to a file in the specified directory

Parameters:

directory (str) – Path to directory to save oovs_found.txt

property speaker_mapping#

Mapping of speakers to dictionaries

word_mapping(dictionary_id=None)[source]#

Get the word mapping for a specified dictionary id

Parameters:

dictionary_id (int, optional) – Database ID for dictionary, defaults to 1

Returns:

Mapping from words to their integer IDs for Kaldi processing

Return type:

dict[str, int]

words_for_export(dictionary_id=None, write_disambiguation=False, probability=False)[source]#

Generate exportable pronunciations

Parameters:
  • dictionary_id (int, optional) – Dictionary id to export, defaults to the default dictionary

  • write_disambiguation (bool, optional) – Flag for whether to include disambiguation information

  • probability (bool, optional) – Flag for whether to include probabilities

Returns:

List of pronunciations as dictionaries

Return type:

list[dict[str,Any]]

write_lexicon_information(write_disambiguation=False)[source]#

Write all child dictionaries to the temporary directory

Parameters:

write_disambiguation (bool, optional) – Flag to use disambiguation symbols in the output

write_training_information()[source]#

Write phone information needed for training