MontrealCorpusTools / Montreal-Forced-Aligner

Command line utility for forced alignment using Kaldi
https://montrealcorpustools.github.io/Montreal-Forced-Aligner/
MIT License
1.27k stars 242 forks source link

[BUG] Can't run mfa after installation: syntax error in multiprocessing.py #698

Closed dreamk73 closed 10 months ago

dreamk73 commented 11 months ago

Debugging checklist

[ X] Have you updated to latest MFA version? [ ] Have you tried rerunning the command with the --clean flag?

Describe the issue A clear and concise description of what the bug is.

I just installed the montreal forced aligner using the conda command in the readme.md file. I have python 3.8 installed and numpy 1.24.4 in a clean conda environment. Whatever I try to do, I just get a syntax error in multiprocessing.py:

File "~/miniconda3/envs/py38-fairseq/bin/mfa", line 6, in from montreal_forced_aligner.command_line.mfa import mfa_cli File "~/miniconda3/envs/py38-fairseq/lib/python3.8/site-packages/montreal_forced_aligner/init.py", line 4, in import montreal_forced_aligner.acoustic_modeling as acoustic_modeling File "~/miniconda3/envs/py38-fairseq/lib/python3.8/site-packages/montreal_forced_aligner/acoustic_modeling/init.py", line 7, in from montreal_forced_aligner.acoustic_modeling.base import AcousticModelTrainingMixin # noqa File "~/miniconda3/envs/py38-fairseq/lib/python3.8/site-packages/montreal_forced_aligner/acoustic_modeling/base.py", line 21, in from montreal_forced_aligner.alignment import AlignMixin File "~/miniconda3/envs/py38-fairseq/lib/python3.8/site-packages/montreal_forced_aligner/alignment/init.py", line 6, in from montreal_forced_aligner.alignment.adapting import AdaptingAligner File "~/miniconda3/envs/py38-fairseq/lib/python3.8/site-packages/montreal_forced_aligner/alignment/adapting.py", line 19, in from montreal_forced_aligner.alignment.multiprocessing import AccStatsArguments, AccStatsFunction File "~/miniconda3/envs/py38-fairseq/lib/python3.8/site-packages/montreal_forced_aligner/alignment/multiprocessing.py", line 407 self.session() as session, ^

For Reproducing your issue Please fill out the following:

  1. Corpus structure
    • What language is the corpus in?
    • How many files/speakers?
    • Are you using lab files or TextGrid files for input?
  2. Dictionary
    • Are you using a dictionary from MFA? If so, which one?
    • If it's a custom dictionary, what is the phoneset?
  3. Acoustic model
    • If you're using an acoustic model, is it one download through MFA? If so, which one?
    • If it's a model you've trained, what data was it trained on?

Log file Please attach the log file for the run that encountered an error (by default these will be stored in ~/Documents/MFA).

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

scutcsq commented 11 months ago

I got the same problem when I tried the command from https://montreal-forced-aligner.readthedocs.io/en/latest/first_steps/index.html#first-steps "mfa model download acoustic english_us_arpa", and I still do not know how to solve it.

mmcauliffe commented 10 months ago

That is very odd, that line definitely doesn't have a syntax error that should be thrown on any recent version of python and all the conda forge builds have been fine. The line in question: https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/blob/main/montreal_forced_aligner/alignment/multiprocessing.py#L407 shouldn't have an issue with python 3.8. Can you try creating a new environment and installing there? Alternatively, you can try using python 3.11, but I don't think there's anything new in recent version of python that would affect those lines.

dreamk73 commented 10 months ago

A new environment with python 3.11 works. I am currently trying a new environment with 3.8 and it has been trying to solve the environment for the past few hours and appears to be stuck.

evdv commented 10 months ago

The offending lines are 403-406 (https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/blob/16292fa012a2f735db47ba4b8d2705303a94085a/montreal_forced_aligner/alignment/multiprocessing.py#L403) Python version 3.8 does not support parenthesized context expressions. To be Python 3.8 compliant, the context statement would need to look as follows:

with self.session() as session, thread_logger("kalpy.graphs", self.log_path, job_name=self.job_name) as graph_logger:

For which the whitespace would need to reorganised as well.

The same issue also occurs on lines 462, 539, 620, 789, 1249