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] TrainableAligner() got multiple values for keyword argument 'phone_groups_path' #767

Closed AlienKevin closed 4 months ago

AlienKevin commented 4 months ago

Debugging checklist

[x] Have you read the troubleshooting page (https://montreal-forced-aligner.readthedocs.io/en/latest/user_guide/troubleshooting.html) and searched the documentation to ensure that your issue is not addressed there? [x] Have you updated to latest MFA version? What is the output of mfa version? [x] Have you tried rerunning the command with the --clean flag?

Describe the issue Using MFA 3.0.0 to train an acoustic model with custom phone_groups_path throw an exception. Command:

mfa train train_wavs lexicon.txt yue_acoustic_model.zip --output_directory train_alignment/ --num_jobs 32 --clean --phone_groups_path cantonese_ipa.yaml

Exception:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/sagemaker-user/.conda/envs/aligner/bin/mfa", line 10, in <module>
    sys.exit(mfa_cli())
  File "/home/sagemaker-user/.conda/envs/aligner/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/sagemaker-user/.conda/envs/aligner/lib/python3.9/site-packages/rich_click/rich_command.py", line 126, in main
    rv = self.invoke(ctx)
  File "/home/sagemaker-user/.conda/envs/aligner/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sagemaker-user/.conda/envs/aligner/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sagemaker-user/.conda/envs/aligner/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/sagemaker-user/.conda/envs/aligner/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/sagemaker-user/.conda/envs/aligner/lib/python3.9/site-packages/montreal_forced_aligner/command_line/train_acoustic_model.py", line 138, in train_acoustic_model_cli
    trainer = TrainableAligner(
TypeError: montreal_forced_aligner.acoustic_modeling.trainer.TrainableAligner() got multiple values for keyword argument 'phone_groups_path'

It seems that the phone_groups_path is also passed in via the context.params and caused a conflict:

trainer = TrainableAligner(
        corpus_directory=corpus_directory,
        dictionary_path=dictionary_path,
        g2p_model_path=g2p_model_path,
        phone_groups_path=phone_groups_path,
        **TrainableAligner.parse_parameters(config_path, context.params, context.args),
    )

A solution is to delete the line phone_groups_path=phone_groups_path, because context.params already defines phone_groups_path.

Desktop (please complete the following information):