CorpusAligner#

class montreal_forced_aligner.alignment.CorpusAligner(g2p_model_path=None, max_active=2500, lattice_beam=6, **kwargs)[source]#

Bases: AcousticCorpusPronunciationMixin, AlignMixin, FileExporterMixin

Mixin class that aligns corpora with pronunciation dictionaries

See also

AcousticCorpusPronunciationMixin

For dictionary and corpus parsing parameters

AlignMixin

For alignment parameters

FileExporterMixin

For file exporting parameters

align(workflow_name=None)[source]#

Run the aligner

alignment_extraction_arguments()[source]#

Generate Job arguments for AlignmentExtractionFunction

Returns:

Arguments for processing

Return type:

list[AlignmentExtractionArguments]

collect_alignments()[source]#

Process alignment archives to extract word or phone alignments

See also

AlignmentExtractionFunction

Multiprocessing function for extracting alignments

CorpusAligner.alignment_extraction_arguments

Arguments for extraction

compute_pronunciation_probabilities()[source]#

Multiprocessing function that computes pronunciation probabilities from alignments

See also

GeneratePronunciationsFunction

Multiprocessing helper function for each job

CorpusAligner.generate_pronunciations_arguments

Job method for generating arguments for the helper function

align_si.sh

Reference Kaldi script

align_fmllr.sh

Reference Kaldi script

property decode_options#

Options needed for decoding

evaluate_alignments(mapping=None, output_directory=None, comparison_source=WorkflowType.alignment, reference_source=WorkflowType.reference)[source]#

Evaluate alignments against a reference directory

Parameters:
  • mapping (dict[str, Union[str, list[str]]], optional) – Mapping between phones that should be considered equal across different phone set types

  • output_directory (str, optional) – Directory to save results, if not specified, it will be saved in the log directory

  • comparison_source (WorkflowType) – Workflow to compare to the reference intervals, defaults to alignment

  • reference_source (WorkflowType) – Workflow to use as the reference intervals, defaults to reference

export_files(output_directory, output_format=None, include_original_text=False)[source]#

Export a TextGrid file for every sound file in the dataset

Parameters:
  • output_directory (Path) – Directory to save to

  • output_format (str, optional) – Format to save alignments, one of ‘long_textgrids’ (the default), ‘short_textgrids’, or ‘json’, passed to praatio

  • include_original_text (bool) – Flag for including the original text of the corpus files as a tier

export_textgrid_arguments(output_format, include_original_text=False)[source]#

Generate Job arguments for ExportTextGridProcessWorker

Parameters:

output_format (str, optional) – Format to save alignments, one of ‘long_textgrids’ (the default), ‘short_textgrids’, or ‘json’, passed to praatio

Returns:

Arguments for processing

Return type:

list[ExportTextGridArguments]

export_textgrids(output_format='long_textgrid', include_original_text=False)[source]#

Exports alignments to TextGrid files

See also

ExportTextGridProcessWorker

Multiprocessing helper function for TextGrid export

CorpusAligner.export_textgrid_arguments

Job method for TextGrid export

Parameters:

output_format (str, optional) – Format to save alignments, one of ‘long_textgrids’ (the default), ‘short_textgrids’, or ‘json’, passed to praatio

fine_tune_alignments()[source]#

Fine tune aligned boundaries to millisecond precision

fine_tune_arguments()[source]#

Generate Job arguments for FineTuneFunction

Returns:

Arguments for processing

Return type:

list[FineTuneArguments]

generate_pronunciations_arguments()[source]#

Generate Job arguments for GeneratePronunciationsFunction

Returns:

Arguments for processing

Return type:

list[GeneratePronunciationsArguments]

property hclg_options#

Options for constructing HCLG FSTs

property score_options#

Options needed for scoring lattices