MontrealCorpusTools / Montreal-Forced-Aligner

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

[BUG] #748

Closed LeoncioC7 closed 4 months ago

LeoncioC7 commented 5 months ago

Debugging checklist

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

Describe the issue I installed/open mfa using Anaconda. Every time I try to validate my corpus, I receive this error. It is the first time it has happened, but I haven't used MFA in a few months, so I'm not sure about the problem. I'd appreciate any help on how to fix this, I'm getting stuck and need to finish this for a conference in a few weeks. P.S. I'm not a coder/familiar with these processes by any means. Screenshot 2024-02-14 at 1 39 26 PM

ERROR There was an error in the run, please see the log.
Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/abc.py", line 82, in run self._run() File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/alignment/multiprocessing.py", line 1315, in _run ctm = lexicon_compiler.phones_to_pronunciations( TypeError: phones_to_pronunciations() got multiple values for argument 'transcription'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/leonardocarvajal/anaconda3/envs/aligner/bin/mfa", line 10, in sys.exit(mfa_cli()) File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/rich_click/rich_command.py", line 126, in main rv = self.invoke(ctx) File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/click/core.py", line 783, in invoke return __callback(args, *kwargs) File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), args, **kwargs) File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/command_line/validate.py", line 112, in validate_corpus_cli validator.validate() File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/validation/corpus_validator.py", line 512, in validate self.train() File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/acoustic_modeling/trainer.py", line 536, in train self.finalize_training() File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/acoustic_modeling/trainer.py", line 601, in finalize_training self.collect_alignments() File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/alignment/base.py", line 693, in collect_alignments for ( File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/utils.py", line 654, in run_kaldi_function raise v File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/utils.py", line 538, in run self.function.run() File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/abc.py", line 86, in run raise MultiprocessingError(self.job_name, error_text) montreal_forced_aligner.exceptions.MultiprocessingError: MultiprocessingError:

Job 1 encountered an error: Traceback (most recent call last):

File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/abc.py", line 82, in run self._run()

File "/Users/leonardocarvajal/anaconda3/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/alignment/multiprocessing.py", line 1315, in _run ctm = lexicon_compiler.phones_to_pronunciations(

TypeError: phones_to_pronunciations() got multiple values for argument 'transcription'

For Reproducing your issue Please fill out the following:

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

Log file Please attach the log file for the run that encountered an error (by default these will be stored in ~/Documents/MFA). I'm not sure I'm attaching the correct one, but here it is. cmvn.log generate_final_features.1.log make_mfcc.1.log normalize_oov.log

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

domklement commented 5 months ago

It's happening to me right now as well. I'm using the latest version 3.0.0a8.

The obvious issue is that the method phones_to_pronunciations takes 3 arguments but in the alignment.py, the authors call it with 4 (last one is transcription=False, hence the error). I'm trying to decode the semantics of the methods and fix the error, but would welcome any help from the authors as well.

Edit: It takes 4 arguments but the problem is that the order does not correspond to the order defined by the phones_to_pronunciations method.

A quick fix is to edit montreal_forced_aligner/alignment/multiprocessing.py

ctm = lexicon_compiler.phones_to_pronunciations(
    alignment.words,
    intervals,
    transcription=False,
    text=utterance_texts[utterance]
)

The same error happens in montreal_forced_aligner/online/alignment.py as well. Again, a quick fix:

ctm = lexicon_compiler.phones_to_pronunciations(
    alignment.words, phone_intervals, transcription=False, text=utterance.transcript
)

I assume a similar issue to be present in multiple files, so it would be good to check and fix all such errors.

Hope this helps.

Dominik

domklement commented 5 months ago

@mmcauliffe - The issues are caused by your recent updates to https://github.com/mmcauliffe/kalpy (last 3 commits). I think it would be the best to force MFA to use the older kalpy version as it would fix loads of issues we're facing right now.

LeoncioC7 commented 5 months ago

Hi domklement

It's happening to me right now as well. I'm using the latest version 3.0.0a8.

The obvious issue is that the method phones_to_pronunciations takes 3 arguments but in the alignment.py, the authors call it with 4 (last one is transcription=False, hence the error). I'm trying to decode the semantics of the methods and fix the error, but would welcome any help from the authors as well.

Edit: It takes 4 arguments but the problem is that the order does not correspond to the order defined by the phones_to_pronunciations method.

A quick fix is to edit montreal_forced_aligner/alignment/multiprocessing.py

ctm = lexicon_compiler.phones_to_pronunciations(
    alignment.words,
    intervals,
    transcription=False,
    text=utterance_texts[utterance]
)

ctm = lexicon_compiler.phones_to_pronunciations(
    alignment.words, phone_intervals, transcription=False, text=utterance.transcript
)
--------------------------------------------

Thank you so much for taking the time to read over this issue, Dominik. Since I'm not very familiar with coding (I just asked chatgpt how to edit a package and see the code no), but where in the code should I put your edits. I didn't find any lines starting with

ctm = lexicon_compiler.phones_to_pronunciations

Also, how do I forced MFA to use an older version of kalpi. I checked the link you included in your reply, but I don't see a way to download older versions.

Again, thank you so much for your help.

Leonardo

domklement commented 5 months ago

Hi @LeoncioC7

Given your issue, I assume you are using the latest MFA version. What files did you try to search through?

Forcing MFA to use an older kalpy version can be done by replacing the kalpy module version (I tried it manually, but I don't recommend this). Another way is to install an older version of kalpy-kaldi, 0.5.8 perhaps but I'm not sure about the compatibility - I first used MFA and looked into the source code a few hours ago.

To fix the package, I manually edited the aformentioned files (you need to find your python package directory path and then directory named montreal-forced-aligner). I tried not to touch kalpy as it would be a huge mess, so I recommend editing MFA package only.

LeoncioC7 commented 5 months ago

Yes, I'm using the latest version. I tried to edit the multiprocessing.py package but couldn't find that line in my package. What I'm gonna do is downgrade MFA to a more stable and older version and see how it goes. I'll keep you posted.

yeungpinghei commented 4 months ago

I'm running into a similar problem whenever I try to validate or align no matter what acoustic model or dictionary I use. I'm also using the latest version 3.0.0a8. My OS is OSX and the version is Monterey 12.3.1.

This is what happens when I run validate Exception ignored in atexit callback: <bound method ExitHooks.history_save_handler of <montreal_forced_aligner.command_line.mfa.ExitHooks object at 0x104a9c7f0>> Traceback (most recent call last): File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/mfa.py", line 107, in history_save_handler raise self.exception File "/Users/ping/anaconda3/envs/aligner/bin/mfa", line 10, in sys.exit(mfa_cli()) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/rich_click/rich_command.py", line 126, in main rv = self.invoke(ctx) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(args, *kwargs) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), args, **kwargs) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/validate.py", line 112, in validate_corpus_cli validator.validate() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/validation/corpus_validator.py", line 512, in validate self.train() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/acoustic_modeling/trainer.py", line 536, in train self.finalize_training() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/acoustic_modeling/trainer.py", line 601, in finalize_training self.collect_alignments() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/alignment/base.py", line 693, in collect_alignments for ( File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/utils.py", line 654, in run_kaldi_function raise v File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/utils.py", line 538, in run self.function.run() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/abc.py", line 86, in run raise MultiprocessingError(self.job_name, error_text) montreal_forced_aligner.exceptions.MultiprocessingError: MultiprocessingError:

Job 1 encountered an error: Traceback (most recent call last):

File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/abc.py", line 82, in run self._run()

File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/alignment/multiprocessing.py", line 1315, in _run ctm = lexicon_compiler.phones_to_pronunciations(

TypeError: LexiconCompiler.phones_to_pronunciations() got multiple values for argument 'transcription'

When I run align it shows a different error message. Exception ignored in atexit callback: <bound method ExitHooks.history_save_handler of <montreal_forced_aligner.command_line.mfa.ExitHooks object at 0x1241536d0>> Traceback (most recent call last): File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/mfa.py", line 107, in history_save_handler raise self.exception File "/Users/ping/anaconda3/envs/aligner/bin/mfa", line 10, in sys.exit(mfa_cli()) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/rich_click/rich_command.py", line 126, in main rv = self.invoke(ctx) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(args, *kwargs) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), args, **kwargs) File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/align.py", line 122, in align_corpus_cli aligner.align() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/alignment/pretrained.py", line 334, in align super().align() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/alignment/base.py", line 374, in align self.calc_fmllr() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/corpus/acoustic_corpus.py", line 709, in calcfmllr for in run_kaldi_function(CalcFmllrFunction, arguments, pbar.update): File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/utils.py", line 654, in run_kaldi_function raise v File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/utils.py", line 538, in run self.function.run() File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/abc.py", line 86, in run raise MultiprocessingError(self.job_name, error_text) montreal_forced_aligner.exceptions.MultiprocessingError: MultiprocessingError:

Job 2 encountered an error: Traceback (most recent call last):

File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/abc.py", line 82, in run self._run()

File "/Users/ping/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/corpus/features.py", line 497, in _run computer = FmllrComputer(

TypeError: FmllrComputer.init() got an unexpected keyword argument 'two_models'

AlienKevin commented 4 months ago

The two_models issue is because of a recent api update in kalpy, see https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/issues/742#issuecomment-1928578189

Current workaround for both issues without doing any patching is to install a prior version of kalpy when creating the Conda environment:

conda create -n aligner -c conda-forge montreal-forced-aligner kalpy=0.5.9

yeungpinghei commented 4 months ago

The two_models issue is because of a recent api update in kalpy, see #742 (comment)

Current workaround for both issues without doing any patching is to install a prior version of kalpy when creating the Conda environment:

conda create -n aligner -c conda-forge montreal-forced-aligner kalpy=0.5.9

It worked for me. Thanks so much for your help!

LeoncioC7 commented 4 months ago

It also worked for me, thanks a lot for your help.

mmcauliffe commented 4 months ago

Sorry for the delay, MFA 3.0.0rc1 is out now that supports the latest version of kalpy and fixes a slew of bugs!