### Install MFA from GitHub Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install MFA directly from its GitHub repository. ```bash pip install git+https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner.git ``` -------------------------------- ### Install MFA from Source Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install MFA from its source repository after cloning. Ensure Kaldi and other dependencies are on the system path. ```bash python setup.py install ``` ```bash pip install -e . ``` ```bash python setup.py develop ``` -------------------------------- ### Install MFA from PyPI Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install the latest stable version of MFA from the Python Package Index. ```bash pip install montreal-forced-aligner ``` -------------------------------- ### Install and Verify MFA Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Install MFA using conda-forge and verify the installation. Optionally, install SpeechBrain support and set up Docker. ```bash conda create -n aligner -c conda-forge montreal-forced-aligner conda activate aligner mfa version mfa_update conda install pytorch torchaudio cpuonly -c pytorch pip install speechbrain docker image pull mmcauliffe/montreal-forced-aligner:latest docker run -it -v /path/to/data:/data mmcauliffe/montreal-forced-aligner:latest # Inside container: mfa model download acoustic english_mfa mfa align /data/corpus /data/english_us_mfa.dict english_mfa /data/output ``` -------------------------------- ### start_server Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/reference/server/index.rst Starts the MFA server. ```APIDOC ## start_server ### Description Starts the MFA server. ### Method Not specified (likely a function call within the SDK) ### Endpoint Not applicable (function call) ### Parameters No parameters are explicitly documented. ``` -------------------------------- ### Dockerfile for Installing MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst A sample Dockerfile demonstrating how to install MFA within a custom container using mambaforge. It sets up a user and environment for MFA. ```docker FROM condaforge/mambaforge:22.11.1-4 as build RUN mkdir -p /mfa RUN mamba create -p /env -c conda-forge montreal-forced-aligner RUN useradd -ms /bin/bash mfauser RUN chown -R mfauser /mfa RUN chown -R mfauser /env USER mfauser ENV MFA_ROOT_DIR=/mfa RUN conda run -p /env mfa server init RUN echo "source activate /env && mfa server start" > ~/.bashrc ENV PATH /env/bin:$PATH ``` -------------------------------- ### Install PyTorch (CPU) Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install PyTorch, torchvision, and torchaudio for CPU-only usage. The '-c pytorch' flag specifies the pytorch channel. ```bash conda install pytorch torchvision torchaudio cpuonly -c pytorch ``` -------------------------------- ### Install PyTorch (GPU) Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install PyTorch, torchvision, and torchaudio with CUDA support for GPU usage. '-c pytorch' and '-c nvidia' specify the respective channels. ```bash conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia ``` -------------------------------- ### Install Mandarin Dependencies Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Install Mandarin-specific dependencies using pip. ```bash pip install spacy-pkuseg dragonmapper hanziconv ``` -------------------------------- ### Install Japanese Dependencies Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Install Japanese-specific dependencies using conda. ```bash conda install -c conda-forge spacy sudachipy sudachidict-core ``` -------------------------------- ### Verify MFA Installation Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Check if MFA is installed and accessible from the console. ```bash mfa -h ``` -------------------------------- ### Using Per-Speaker Dictionaries in MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/dictionary.rst Command-line example demonstrating how to use a per-speaker dictionary configuration file with the 'mfa align' command. ```bash mfa align /path/to/corpus /path/to/speaker_dictionaries.yaml /path/to/acoustic_model.zip /path/to/output ``` -------------------------------- ### User and Environment Setup in Dockerfile Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst This snippet from a Dockerfile shows the creation of a dedicated user ('mfauser'), ownership changes for directories, setting the MFA root directory, and initializing the MFA server within the environment. ```docker RUN useradd -ms /bin/bash mfauser RUN chown -R mfauser /mfa RUN chown -R mfauser /env USER mfauser ENV MFA_ROOT_DIR=/mfa RUN conda run -p /env mfa server init ``` -------------------------------- ### Phone Set Mapping Example Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/index.rst An example of a YAML file used to map phones from one set to another. This is required for the 'mfa remap_dictionary' command. ```yaml aj: AY1 aw: AW1 b: B ... m̩: AH0 M ... ``` -------------------------------- ### Install Mamba Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install mamba, a faster drop-in replacement for conda, in your base conda environment. ```bash conda install -c conda-forge mamba ``` -------------------------------- ### Install SpeechBrain via Pip Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install the SpeechBrain library using pip after ensuring you are in the correct conda environment and have PyTorch installed. ```bash pip install speechbrain ``` -------------------------------- ### Install Anchor Subpackage Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/corpus_creation/anchor.rst Install the anchor subpackage for MFA using conda. This command installs MFA if it is not already present, along with all required packages for Anchor. ```bash conda install montreal-forced-aligner[anchor] ``` -------------------------------- ### Install MFA in Develop Mode Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/README.md Install MFA in editable (develop) mode using pip. This allows you to make changes to the source code and have them reflected immediately. The `[dev]` extra installs development dependencies. ```bash pip install -e .[dev] ``` -------------------------------- ### Install Stable 2.1 Release of MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install a specific older version (2.1.7) of MFA along with its compatible versions of openfst and kaldi. ```bash conda install -c conda-forge montreal-forced-aligner=2.1.7 openfst=1.8.2 kaldi=5.5.1068 ``` -------------------------------- ### Install Stable 2.0 Release of MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install a specific older version (2.0.6) of MFA along with its compatible versions of openfst and kaldi. ```bash conda install -c conda-forge montreal-forced-aligner=2.0.6 openfst=1.8.2 kaldi=5.5.1068 ``` -------------------------------- ### YAML Phone Mapping Format Example Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Example of the YAML format for phone set mapping files. Keys are source phone set symbols, and values are target phone set symbols. ```yaml # ipa_to_arpa_mapping.yaml: # p: P # b: B # t: T # d: D # aɪ: AY ``` -------------------------------- ### Manage MFA Database Servers via CLI Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/server/index.rst Use the 'mfa server' subcommands to manage PostgreSQL servers, including initialization, starting, stopping, and deletion. ```bash mfa server ``` -------------------------------- ### List Acoustic Models Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/models/index.rst Lists currently saved acoustic models. Initially, this will be empty after installation. ```bash mfa model list acoustic ``` -------------------------------- ### Install Stable 2.2 Release of MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install a specific older version (2.2.17) of MFA along with its compatible versions of openfst and kaldi. ```bash conda install -c conda-forge montreal-forced-aligner=2.2.17 openfst=1.8.2 kaldi=5.5.1068 ``` -------------------------------- ### Install Specific MFA Version Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Install a specific version of the Montreal Forced Aligner by appending '=X.X.X' to the package name. ```bash conda install montreal-forced-aligner=X.X.X ``` -------------------------------- ### Install MFA with Conda Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/getting_started.rst Installs the Montreal Forced Aligner using conda. This involves adding the conda-forge channel, creating a new environment, activating it, and verifying the installation with the help command. ```bash conda config --add channels conda-forge conda create -n aligner montreal-forced-aligner conda activate aligner mfa --help ``` -------------------------------- ### Run MFA Docker Container Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Start an interactive Docker container for MFA, mounting a local directory to '/data' inside the container for data access. The path before the colon is local, and after is inside the container. ```bash docker run -it -v /path/to/data/directory:/data mmcauliffe/montreal-forced-aligner:latest ``` -------------------------------- ### Adapt using reference (gold) alignments to guide adaptation Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt This method uses reference (gold) alignments to guide the model adaptation process. ```APIDOC ## Adapt using reference (gold) alignments to guide adaptation ### Description Guides the model adaptation process using provided reference (gold) alignments. ### Command Line Usage ```bash mfa adapt /corpus/target /path/to/dict.dict english_mfa /output/adapted.zip \ --reference_directory /path/to/gold_alignments ``` ``` -------------------------------- ### Default Ivector Training Configuration Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/configuration/ivector.rst This YAML configuration file demonstrates the available options for both DUBM and i-vector training, reflecting the settings used in the MFA 2.0 training regime. It serves as an example for understanding the configuration structure and parameters. ```yaml features: type: "mfcc" use_energy: true frame_shift: 10 training: - dubm: num_iterations: 4 num_gselect: 30 num_gaussians: 256 num_iterations_init: 20 - ivector: ivector_dimension: 128 num_iterations: 10 gaussian_min_count: 100 silence_weight: 0.0 posterior_scale: 0.1 max_count: 100 ``` -------------------------------- ### Create Conda Environment for MFA (Windows) Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Create a new conda environment named 'aligner' with Kaldi installed for Windows. ```bash conda create -n aligner kaldi ``` -------------------------------- ### Download Pretrained Models in Docker Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Inside the MFA Docker container, use this command to download pretrained acoustic models, for example, the English model. ```bash mfa model download acoustic english_mfa ``` -------------------------------- ### Install MFA Dependencies via Conda Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/README.md Alternatively, install MFA dependencies individually using conda. This command lists common dependencies for MFA. ```bash conda install -c conda-forge python=3.11 kaldi librosa praatio tqdm requests colorama pyyaml pynini openfst baumwelch ngram ``` -------------------------------- ### Create Conda Environment for MFA (Linux/macOS) Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Create a new conda environment named 'aligner' with Kaldi and Pynini installed for Linux or macOS. ```bash conda create -n aligner kaldi pynini ``` -------------------------------- ### Update MFA Model CLI Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/changelog/index.md Example of how to update an MFA model with new pronunciations from a G2Pped file. ```bash mfa model update /path/to/g2pped_file.txt ``` -------------------------------- ### Create Conda Environment and Install MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Use this command to create a new conda environment named 'aligner' and install the Montreal Forced Aligner. The '-c conda-forge' flag specifies the conda-forge channel. ```bash conda create -n aligner -c conda-forge montreal-forced-aligner ``` -------------------------------- ### Install Stable 3.0 Release of MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Update to the latest version within the 3.0 release series of the Montreal Forced Aligner. ```bash conda update -c conda-forge montreal-forced-aligner ``` -------------------------------- ### Adapt a model and save the adapted version Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt This section details how to adapt an existing acoustic model to a target domain and save the adapted model. It includes command-line usage and a Python API example. ```APIDOC ## Adapt a model and save the adapted version ### Description Adapts an existing acoustic model to a target domain and saves the adapted version. ### Command Line Usage ```bash mfa adapt /corpus/target_domain \ /path/to/dict.dict \ english_mfa \ /output/adapted_model.zip ``` ### Python API ```python from montreal_forced_aligner.alignment import AdaptingAligner adapter = AdaptingAligner( corpus_directory="/corpus/target", dictionary_path="/path/to/dict.dict", acoustic_model_path="english_mfa", ) try: adapter.adapt() adapter.export_model("/output/adapted_model.zip") finally: adapter.cleanup() ``` ``` -------------------------------- ### PostgreSQL Configuration for MFA Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/server/index.rst These are the default PostgreSQL configuration values overridden by MFA during initialization. Tune these further based on your setup and corpus. ```ini log_min_duration_statement = 5000 enable_partitionwise_join = on enable_partitionwise_aggregate = on unix_socket_directories = '/path/to/current/profile/socket_directory' listen_addresses = '' maintenance_work_mem = 1GB work_mem = 128MB shared_buffers = 256MB max_connections = 1000 ``` -------------------------------- ### Example Phone Groupings in YAML Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/implementations/phone_groups.md This YAML snippet demonstrates how to group phonetically similar phones together. Use this to specify custom phone groups for acoustic modeling. ```yaml - - t - tʷ - tʰ - tʲ - - d - dʲ - - ɾ - ɾʲ - - ʔ ``` -------------------------------- ### Python API for model adaptation Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt This Python code demonstrates how to adapt an acoustic model using the AdaptingAligner class. It includes setup, adaptation, model export, and cleanup steps. Ensure all paths and model names are correct. ```python from montreal_forced_aligner.alignment import AdaptingAligner adapter = AdaptingAligner( corpus_directory="/corpus/target", dictionary_path="/path/to/dict.dict", acoustic_model_path="english_mfa", ) try: adapter.adapt() adapter.export_model("/output/adapted_model.zip") finally: adapter.cleanup() ``` -------------------------------- ### Default Diarization Configuration Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/configuration/diarization.rst This is an example of a default configuration file for diarization. It specifies parameters like the clustering algorithm, energy scaling, and segment length. ```yaml cluster_type: optics energy_mean_scale: 0.5 max_segment_length: 30 min_pause_duration: 0.05 ``` -------------------------------- ### Phone mapping YAML for remapping alignments Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/workflows/remap.rst Example of a phone mapping YAML file for remapping alignment phone tiers. This format is stricter than for dictionary remapping, requiring a single target phone per source phone. ```yaml aj: AY1 aw: AW1 b: B bʲ: B c: K cʰ: K cʷ: K d: D dʒ: JH dʲ: D ej: EY1 f: F fʲ: F h: HH i: IY0 iː: IY1 ... ``` -------------------------------- ### initialize_server Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/reference/server/index.rst Initializes a new MFA server. ```APIDOC ## initialize_server ### Description Initializes a new MFA server. ### Method Not specified (likely a function call within the SDK) ### Endpoint Not applicable (function call) ### Parameters No parameters are explicitly documented. ``` -------------------------------- ### Download Dictionary Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/alignment_example.md Download a pretrained dictionary for a specific language. Ensure the dictionary name is correct for your language. ```bash mfa model download dictionary english_us_mfa ``` ```bash mfa model download dictionary japanese_mfa ``` ```bash mfa model download dictionary mandarin_china_mfa ``` -------------------------------- ### Download Japanese Dictionary Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Use this command to download the pretrained Japanese dictionary for adaptation. ```bash mfa model download dictionary japanese_mfa ``` -------------------------------- ### Download Pretrained Models Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/index.rst Use these commands to download the necessary acoustic and dictionary models for a specific language. Ensure the 'mfa' command is accessible in your PATH. ```bash mfa model download acoustic english_us_arpa mfa model download dictionary english_us_arpa ``` -------------------------------- ### Download G2P model for Japanese Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/alignment_example.md Use this command to download the pretrained G2P model for Japanese. ```bash mfa model download g2p japanese_mfa ``` -------------------------------- ### Install MFA via Conda Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/README.md Use this command to install the Montreal Forced Aligner using conda-forge. Ensure you are in your desired environment. ```bash conda install -c conda-forge montreal-forced-aligner ``` -------------------------------- ### Download English Dictionary Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Use this command to download the pretrained US English dictionary for adaptation. ```bash mfa model download dictionary english_us_mfa ``` -------------------------------- ### Download G2P model for English Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/alignment_example.md Use this command to download the pretrained G2P model for US English. ```bash mfa model download g2p english_us_mfa ``` -------------------------------- ### Create Development Environment Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/README.md Create a development environment for MFA using the provided environment.yml file. This is useful for local development and testing. ```bash conda env create -n mfa-dev -f environment.yml ``` -------------------------------- ### Download Pretrained Acoustic Model and Dictionary Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/index.rst Download necessary pretrained acoustic models and pronunciation dictionaries for tasks like remapping. Ensure the 'mfa' command is accessible. ```bash mfa model download acoustic english_us_arpa mfa model download dictionary english_us_mfa ``` -------------------------------- ### Download Japanese JVS Demo Corpus Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Download the Japanese JVS demo corpus for adaptation. ```bash Download the [Japanese JVS demo corpus](https://github.com/MontrealCorpusTools/japanese-jvs-demo/archive/refs/tags/v1.0.0.tar.gz) and extract it to somewhere on your computer ``` -------------------------------- ### Manage MFA Models Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Download, list, inspect, and save pretrained MFA models (acoustic, G2P, dictionaries, language models). ```bash # List all downloadable acoustic models mfa model download acoustic # Download a specific model mfa model download acoustic english_mfa mfa model download dictionary english_us_mfa mfa model download g2p english_us_mfa mfa model download language_model english_mfa # Download a specific version of a model mfa model download acoustic english_mfa --version 3.0.0 # List locally saved models of a given type mfa model list acoustic mfa model list dictionary # Inspect metadata of a downloaded model mfa model inspect acoustic english_mfa # Output includes: version, phone_set, features, training data info, etc. # Save a custom-trained model under a friendly name for reuse mfa model save acoustic /path/to/my_model.zip --name my_english_model # Now usable as: mfa align ... my_english_model ... # Add pronunciations from a supplementary dictionary into a base dictionary mfa model add_words /path/to/base.dict /path/to/extra_words.dict ``` -------------------------------- ### Download English LibriSpeech Demo Corpus Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Download the English LibriSpeech demo corpus for adaptation. ```bash Download the [English LibriSpeech demo corpus](https://github.com/MontrealCorpusTools/librispeech-demo/archive/refs/tags/v1.0.0.tar.gz) and extract it to somewhere on your computer ``` -------------------------------- ### Acoustic-model-guided segmentation Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Segments audio files using an acoustic model to guide the process. ```APIDOC ## segment /corpus/long_recordings /path/to/dict.dict english_mfa /output/segments ### Description Segments audio files using an acoustic model. ### Method CLI Command ### Endpoint mfa segment ### Parameters #### Path Parameters - **/corpus/long_recordings** (string) - Required - Directory containing audio files to segment. - **/path/to/dict.dict** (string) - Required - Path to the dictionary file. - **english_mfa** (string) - Required - Path to the acoustic model. - **/output/segments** (string) - Required - Directory for output segment files. ``` -------------------------------- ### Download Pretrained Model by Type Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/models/index.rst Downloads pretrained models for alignment or pronunciation dictionaries. Replace with 'acoustic', 'g2p', or 'dictionary'. ```bash mfa model download ``` -------------------------------- ### Run MFA Update Utility Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Use the 'mfa_update' utility to fetch the latest versions of MFA, Kalpy, and Kaldi. This is available in MFA version 3.0.5 and later. ```bash mfa_update ``` -------------------------------- ### SpeechBrain-based Transcription Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Transcribes audio files using the SpeechBrain toolkit. Requires speechbrain to be installed. ```bash mfa transcribe_speechbrain /corpus/audio english /output/transcriptions \ --architecture wav2vec2 ``` -------------------------------- ### Download Mandarin Acoustic Model Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Use this command to download the pretrained Mandarin acoustic model for adaptation. ```bash mfa model download acoustic mandarin_mfa ``` -------------------------------- ### SpeechBrain-based transcription Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Transcribes audio files using a SpeechBrain-based model. Requires the speechbrain library to be installed. ```APIDOC ## transcribe_speechbrain /corpus/audio english /output/transcriptions ### Description Transcribes audio files using a SpeechBrain-based model. ### Method CLI Command ### Endpoint mfa transcribe_speechbrain ### Parameters #### Path Parameters - **/corpus/audio** (string) - Required - Directory containing audio files. - **english** (string) - Required - Language of the audio. - **/output/transcriptions** (string) - Required - Directory for output transcriptions. #### Query Parameters - **--architecture** (string) - Optional - Specifies the architecture of the SpeechBrain model (e.g., wav2vec2). ``` -------------------------------- ### Download Acoustic Model Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/alignment_example.md Download a pretrained acoustic model for a specific language. Ensure the model name is correct for your language. ```bash mfa model download acoustic english_mfa ``` ```bash mfa model download acoustic japanese_mfa ``` ```bash mfa model download acoustic mandarin_mfa ``` -------------------------------- ### Uninstall Montreal Forced Aligner (pip) Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Remove any existing pip installation of MFA before upgrading via Conda. ```bash pip uninstall montreal-forced-aligner ``` -------------------------------- ### Download G2P model for Mandarin Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/alignment_example.md Use this command to download the pretrained G2P model for Mandarin Chinese. ```bash mfa model download g2p mandarin_china_mfa ``` -------------------------------- ### Example French clitic normalization Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/dictionary.rst Demonstrates how French clitics marked with apostrophes are handled during text normalization and dictionary lookup. ```none c'est S E c S E c' S etait E T E un A N ``` ```none c'est un c c'etait un c ``` ```none S E A N S E S E T E A N S E ``` -------------------------------- ### Download Mandarin China Dictionary Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Use this command to download the pretrained China Mandarin dictionary for adaptation. ```bash mfa model download dictionary mandarin_china_mfa ``` -------------------------------- ### Download Pretrained G2P Model Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/index.rst Download a pretrained G2P (Grapheme-to-Phoneme) model for generating pronunciation dictionaries. This is a prerequisite for using the 'mfa g2p' command. ```bash mfa model download g2p english_us_arpa ``` -------------------------------- ### Download Mandarin THCHS-30 Demo Corpus Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Download the Mandarin THCHS-30 demo corpus for adaptation. ```bash Download the [Mandarin THCHS-30 demo corpus](https://github.com/MontrealCorpusTools/mandarin-thchs-30-demo/archive/refs/tags/v1.0.0.tar.gz) and extract it to somewhere on your computer ``` -------------------------------- ### Transcriber Class Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/reference/transcription/main.rst The Transcriber class is the main entry point for using the transcription functionality. It handles the setup and execution of transcription jobs. ```APIDOC ## Transcriber ### Description The Transcriber class is the primary interface for performing transcription tasks within the Montreal Forced Aligner. It encapsulates the logic for setting up and running transcription processes. ### Usage Instantiate the Transcriber class and use its methods to manage transcription jobs. ```python from montreal_forced_aligner.transcription import Transcriber # Example usage (details of methods and parameters would be further documented) transcriber = Transcriber(config) transcriber.transcribe(corpus_path, output_directory) ``` ### Methods (Specific methods like `transcribe`, `train`, etc., would be detailed here with their parameters and return values if documented in the source.) ### Parameters (Parameters for the `Transcriber` constructor and its methods would be detailed here if documented in the source.) ### Returns (Return values for `Transcriber` methods would be detailed here if documented in the source.) ``` -------------------------------- ### MFA Dictionary Pronunciations Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/dictionary.rst Example pronunciations generated by MFA for specific words and cutoff patterns, including silence ('spn') and phonetic transcriptions. ```text spn spn kʰ ɐ t kʰ ɐ spn ɒ f ɒ ɑ f ɑ ``` -------------------------------- ### Set Beam Width via YAML Configuration File Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/configuration/index.rst For more complex configurations, define parameters in a YAML file and reference it using the `--config_path` argument. This allows for specifying multiple settings at once. ```yaml beam: 1000 ``` -------------------------------- ### Get Log Likelihood Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/notebooks/debugging_alignments.ipynb Retrieve the log likelihood for a specific frame and state using the Decodable object. This helps in understanding acoustic scoring. ```python like = decodable.LogLikelihood(1, 2) print(like) ``` -------------------------------- ### Load and Prepare Alignment Data Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/notebooks/debugging_alignments.ipynb Load reference phones, features, and training graphs using specified paths. Initialize the GMM aligner with the acoustic model. ```python reference_phone_archive = RandomAccessInt32VectorVectorReader(generate_read_specifier(reference_phones_path)) reference_phones = [x[0] for x in reference_phone_archive.Value(utterance_id)] reference_phones[0] = -1 feature_archive = FeatureArchive( feat_path, lda_mat_file_name=lda_mat_path, ) training_graph_archive = FstArchive(fst_path) training_graph = training_graph_archive[utterance_id] features = feature_archive[utterance_id] aligner = GmmAligner(model_path) print(len(reference_phones)) print(features.NumRows()) ``` -------------------------------- ### SpeechBrain VAD Segmentation with CUDA Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Segments audio using SpeechBrain's VAD model, leveraging CUDA for GPU acceleration. Requires speechbrain installation. ```bash mfa segment_vad /corpus/long_recordings /output/segments --speechbrain --cuda ``` -------------------------------- ### Align with Reference Phones Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/notebooks/debugging_alignments.ipynb Perform alignment using reference phones as a guide. This function returns detailed alignment information, including likelihoods and success status. ```python ( alignment, words, likelihood, per_frame_log_likelihoods, successful, retried, ) = gmm_align_reference_phones( aligner.transition_model, aligner.acoustic_model, training_graph, features, reference_phones, acoustic_scale=aligner.acoustic_scale, transition_scale=aligner.transition_scale, self_loop_scale=aligner.self_loop_scale, beam=aligner.beam, retry_beam=aligner.retry_beam, careful=aligner.careful, ) print(alignment[:10]) alignment_phones = [aligner.transition_model.TransitionIdToPhone(x) for x in alignment] ``` -------------------------------- ### Define Cot-Caught Merger Rules in YAML Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/implementations/phonological_rules.md Example of defining phonological rules for the cot-caught merger in English, specifying variants for long/short vowels and different following contexts. ```yaml rules: - following_context: $ # caught-cot merger preceding_context: '' replacement: ɑː segment: ɒː - following_context: '[^ɹ]' # caught-cot merger preceding_context: '' replacement: ɑː segment: ɒː - following_context: $ # caught-cot merger preceding_context: '' replacement: ɑ segment: ɒ - following_context: '[^ɹ]' # caught-cot merger preceding_context: '' replacement: ɑ segment: ɒ ``` -------------------------------- ### Acoustic-model-guided Segmentation Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Segments audio files using an acoustic model for guidance. Requires a dictionary and acoustic model path. ```bash mfa segment /corpus/long_recordings /path/to/dict.dict english_mfa \ /output/segments ``` -------------------------------- ### Create Conda Environment with Mamba Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/installation.rst Use mamba to create a new conda environment named 'aligner' and install the Montreal Forced Aligner. This is generally faster than using conda. ```bash mamba create -n aligner -c conda-forge montreal-forced-aligner ``` -------------------------------- ### MFA Alignment Evaluation Output Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md This is an example of the output from the MFA alignment evaluation process when reference directories are provided. It shows average overlap scores and phone error rates. ```text INFO Evaluating alignments... INFO Exporting evaluation... INFO Average overlap score: 0.010834011956534382 INFO Average phone error rate: 0.02820097244732577 ``` -------------------------------- ### Adapt a model and save the adapted version Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Use this command to adapt an existing acoustic model to a target domain and save the adapted model. Ensure the corpus directory, dictionary, acoustic model, and output path are correctly specified. ```bash mfa adapt /corpus/target_domain \ /path/to/dict.dict \ english_mfa \ /output/adapted_model.zip ``` ```bash mfa adapt /corpus/target /path/to/dict.dict english_mfa /output/adapted.zip \ --output_directory /output/alignments ``` ```bash mfa adapt /corpus/target /path/to/dict.dict english_mfa /output/adapted.zip \ --reference_directory /path/to/gold_alignments ``` -------------------------------- ### Complex Phonological Rule Examples in YAML Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/implementations/phonological_rules.md Demonstrates various complex phonological rules including deletion, syllabic 'l' insertion, schwa deletion, consonant cluster simplification, and metathesis. ```yaml rules: - following_context: '' # deleting d after n preceding_context: 'n' replacement: '' segment: d - following_context: '[^ʊɔɝaɛeoæɐɪəɚɑʉɒi].*' # syllabic l preceding_context: '' replacement: ɫ̩ segment: ə ɫ - following_context: '' # schwa deletion preceding_context: '' replacement: ɹ ə segment: 'ə ɹ ə' - following_context: '' preceding_context: '' replacement: dʒ segment: d[ʲʷ]? ɹ - following_context: $ # ask metathesis preceding_context: '' replacement: k s segment: s k ``` -------------------------------- ### configure_pg Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/reference/server/index.rst Configures the PostgreSQL database for the server. ```APIDOC ## configure_pg ### Description Configures the PostgreSQL database for the server. ### Method Not specified (likely a function call within the SDK) ### Endpoint Not applicable (function call) ### Parameters No parameters are explicitly documented. ``` -------------------------------- ### Complex Configuration with YAML Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/configuration/index.rst Define multiple advanced settings, including training parameters, punctuation, and beam widths, within a single YAML configuration file for use with MFA. ```yaml beam: 100 retry_beam: 400 punctuation: ":,." training: - monophone: num_iterations: 20 max_gaussians: 500 subset: 1000 boost_silence: 1.25 - triphone: num_iterations: 35 num_leaves: 2000 max_gaussians: 10000 cluster_threshold: -1 subset: 5000 boost_silence: 1.25 power: 0.25 ``` -------------------------------- ### Remap Japanese to English Dictionary Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/remapping_example.md Use this command to create a Japanese dictionary with English MFA pronunciations. Download the mapping file first. ```bash mfa remap dictionary japanese_mfa english_mfa ~/mfa_data/japanese_to_english_phone_mapping.yaml ~/mfa_data/japanese_english.dict ``` -------------------------------- ### Python API for language model training Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt This Python code uses `MfaLmCorpusTrainer` to train a language model from a corpus directory. It handles the setup, training, and export of the model. Ensure the corpus directory path is correct. ```python from montreal_forced_aligner.language_modeling.trainer import MfaLmCorpusTrainer trainer = MfaLmCorpusTrainer(corpus_directory="/corpus/text_data") try: trainer.setup() trainer.train() trainer.export_model("/output/my_lm.zip") finally: trainer.cleanup() ``` -------------------------------- ### Train a G2P model from a pronunciation dictionary Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Use `mfa train_g2p` to train a new grapheme-to-phoneme model using Pynini or Phonetisaurus. This requires an existing pronunciation dictionary. Options include evaluation on a held-out set and using custom configuration files. ```bash mfa train_g2p /path/to/english_us_mfa.dict /output/my_g2p_model.zip ``` ```bash mfa train_g2p /path/to/dict.dict /output/my_g2p_model.zip --evaluate ``` ```bash mfa train_g2p /path/to/dict.dict /output/my_g2p_model.zip --phonetisaurus ``` ```bash mfa train_g2p /path/to/dict.dict /output/my_g2p_model.zip \ --config_path /path/to/g2p_config.yaml ``` -------------------------------- ### Import Kalpy Debugging Utilities Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/notebooks/debugging_alignments.ipynb Import necessary classes and functions from Kalpy for GMM alignment and data handling. Ensure these are available in your environment. ```python from kalpy.decoder.data import FstArchive from kalpy.gmm.align import GmmAligner from kalpy.feat.data import FeatureArchive from kalpy.utils import generate_read_specifier from _kalpy.util import RandomAccessInt32VectorVectorReader from _kalpy.gmm import gmm_align_compiled, gmm_align_reference_phones from _kalpy.gmm import DecodableAmDiagGmmScaledMasked ``` -------------------------------- ### Default Training Configuration (MFA 2.0) Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/configuration/acoustic_modeling.rst This YAML configuration represents the default training regime for MFA version 2.0, illustrating available configuration options and their progression. ```yaml beam: 10 retry_beam: 40 features: type: "mfcc" use_energy: false use_pitch: true frame_shift: 10 training: - monophone: subset: 10000 num_iterations: 40 max_gaussians: 1000 boost_silence: 1.25 - triphone: subset: 20000 num_iterations: 35 num_leaves: 2000 max_gaussians: 10000 cluster_threshold: -1 boost_silence: 1.25 power: 0.25 - lda: subset: 20000 num_leaves: 2500 max_gaussians: 15000 num_iterations: 35 - sat: subset: 20000 num_leaves: 2500 max_gaussians: 15000 power: 0.2 silence_weight: 0.0 fmllr_update_type: "full" - sat: subset: 50000 num_leaves: 4200 max_gaussians: 40000 power: 0.2 silence_weight: 0.0 fmllr_update_type: "full" - pronunciation_probabilities: subset: 50000 silence_probabilities: true - sat: subset: 150000 num_leaves: 5000 max_gaussians: 100000 power: 0.2 silence_weight: 0.0 fmllr_update_type: "full" - pronunciation_probabilities: subset: 150000 silence_probabilities: true optional: true # Skipped if the corpus is smaller than the subset - sat: subset: 0 quick: true # Performs fewer fMLLR estimation num_iterations: 20 num_leaves: 7000 max_gaussians: 150000 power: 0.2 silence_weight: 0.0 fmllr_update_type: "full" optional: true # Skipped if the corpus is smaller than the previous subset ``` -------------------------------- ### Python API for G2P word list generation Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt This Python code uses `PyniniWordListGenerator` to create pronunciations from a word list. It allows specifying the number of pronunciations and handles setup, generation, and cleanup. Ensure the G2P model path is correct. ```python from montreal_forced_aligner.g2p.generator import PyniniWordListGenerator g2p = PyniniWordListGenerator( word_list_path="/path/to/wordlist.txt", g2p_model_path="/path/to/english_us_mfa.zip", num_pronunciations=2, ) try: g2p.setup() g2p.export_pronunciations("/path/to/output.txt") finally: g2p.cleanup() ``` -------------------------------- ### Train Acoustic Model CLI Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/workflows/train_acoustic_model.rst The command-line interface for training acoustic models. ```APIDOC ## mfa train acoustic_model ### Description Trains an acoustic model using the specified configuration. ### Command ```bash mfa train [--clean] [--overwrite] [--use_mp] [--num_jobs NUM_JOBS] ``` ### Parameters * **config_path** (string) - Required - Path to the configuration file for training. * **--clean** - Optional - Clean intermediate files after training. * **--overwrite** - Optional - Overwrite existing models if they exist. * **--use_mp** - Optional - Use multiprocessing for training. * **--num_jobs** (int) - Optional - Number of jobs to use for multiprocessing. ``` -------------------------------- ### Configure MFA Global Settings Source: https://context7.com/montrealcorpustools/montreal-forced-aligner/llms.txt Set persistent defaults for MFA commands using the `configure` command. Settings are stored in `~/Documents/MFA/global_config.yaml` and can be overridden per-run. ```bash # Set number of parallel jobs to 8 and always clean temp files mfa configure --num_jobs 8 --always_clean # Set a custom temporary directory and enable PostgreSQL backend mfa configure --temporary_directory /scratch/mfa_tmp --enable_use_postgres # Use a named profile (e.g. for multi-project setups) mfa configure --profile production --always_overwrite --never_debug # Set GitHub token for faster model downloads (avoids rate limiting) mfa configure --github_token ghp_XXXXXXXXXXXXXXXX # View current config by inspecting the yaml file directly cat ~/Documents/MFA/global_config.yaml # Expected keys: num_jobs, temporary_directory, clean, use_postgres, verbose, ... ``` -------------------------------- ### Customize Phone Topologies Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/user_guide/concepts/hmm.md Define custom minimum and maximum states for phones in a topology configuration file. This allows for variable modeling of phone durations based on articulation complexity. ```yaml tʃ: - min_states: 3 - max_states: 5 ɾ: - min_states: 1 - max_states: 1 ``` -------------------------------- ### Adapt Japanese Acoustic Model Source: https://github.com/montrealcorpustools/montreal-forced-aligner/blob/main/docs/source/first_steps/alignment_example.md Adapt a pretrained Japanese acoustic model. This command requires specifying the G2P model path. Adapting the model can lead to better alignment results for Japanese data. ```bash mfa adapt ~/mfa_data/japanese-jvs-demo-1.0.0 japanese_mfa japanese_mfa ~/mfa_data/japanese_mfa_adapted.zip --g2p_model_path japanese_mfa --clean ```