MontrealCorpusTools / Montreal-Forced-Aligner

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

ERROR There was an error connecting to the global MFA database server. #588

Closed abinayreddy closed 1 year ago

abinayreddy commented 1 year ago

ERROR There was an error connecting to the global MFA database server.
ERROR Please ensure the server is initialized (mfa server init) or running (mfa server start)
ERROR There was an error in the run, please see the log.
Exception ignored in atexit callback: <bound method ExitHooks.history_save_handler of <montreal_forced_aligner.command_line.mfa.ExitHooks object at 0x7f4c9282f2e0>> Traceback (most recent call last): File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/mfa.py", line 97, in history_save_handler raise self.exception File "/home/abinay/anaconda3/envs/aligner/bin/mfa", line 11, in sys.exit(mfa_cli()) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(*args, kwargs) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/rich_click/rich_group.py", line 21, in main rv = super().main(args, standalone_mode=False, kwargs) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/align.py", line 113, in align_corpus_cli aligner.align() File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/alignment/pretrained.py", line 405, in align self.initialize_database() File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/abc.py", line 241, in initialize_database subprocess.check_call( File "/home/abinay/anaconda3/envs/aligner/lib/python3.10/subprocess.py", line 369, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['createdb', '--host=/home/abinay/Documents/MFA/pg_mfa_global_socket', '19']' returned non-zero exit status 1.

hailthedawn commented 1 year ago

Experiencing the same issue when running the Colab notebook (https://gist.github.com/NTT123/12264d15afad861cb897f7a20a01762e)

mmcauliffe commented 1 year ago

Can you run mfa configure --enable_auto_server and see if that fixes it?

hailthedawn commented 1 year ago

Thanks for the response! It didn't. Now, I'm getting:

The global MFA database server does not exist, initializing it first.
There was an issue initializing the server, please refer to temp/pg_init_log_global.txt for more details
Traceback (most recent call last):
  File "/tmp/mfa/miniconda3/envs/aligner/bin/mfa", line 11, in <module>
    sys.exit(mfa_cli())
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/rich_click/rich_group.py", line 21, in main
    rv = super().main(*args, standalone_mode=False, **kwargs)
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1654, in invoke
    super().invoke(ctx)
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/mfa.py", line 127, in mfa_cli
    start_server()
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/utils.py", line 353, in start_server
    initialize_server()
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/site-packages/montreal_forced_aligner/command_line/utils.py", line 313, in initialize_server
    subprocess.check_call(
  File "/tmp/mfa/miniconda3/envs/aligner/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['initdb', '-D', PosixPath('temp/pg_mfa_global'), '--encoding=UTF8']' returned non-zero exit status 1.
hailthedawn commented 1 year ago

I can make a separate issue for this, but I did get the notebook code running on my local machine. However, when I try it with my own data (a 16khz wav file and its .txt transcript), I get the following error:

(The file is around 4 minutes long, if that's relevant.)

$ mfa align -t ./temp -j 2 ./temp_mfa modified_librispeech-lexicon.txt ./english.zip ./ljs_alignedcapstone
 WARNING  The previous run had a different configuration than the current, which may cause issues. Please see the log for details or use --clean flag if issues 
          are encountered.
 WARNING  The previous run had a different configuration than the current, which may cause issues. Please see the log for details or use --clean flag if issues 
          are encountered.
 INFO     Setting up corpus information...
 INFO     Found 1 speaker across 1 file, average number of utterances per speaker: 1.0
 INFO     Initializing multiprocessing jobs...
 WARNING  Number of jobs was specified as 2, but due to only having 1 speakers, MFA will only use 1 jobs. Use the --single_speaker flag if you would like to    
          split utterances across jobs regardless of their speaker.
 INFO     Text already normalized.
 INFO     Creating corpus split with features...
 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1  [ 0:00:04 < 0:00:00 , ? it/s ] INFO     Features already generated.
 INFO     Compiling training graphs...
 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1  [ 0:00:04 < 0:00:00 , ? it/s ] INFO     Performing first-pass alignment...
 INFO     Generating alignments...
   0% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/1  [ 0:00:14 < -:--:-- , ? it/s ] ERROR    There was an error in the run, please see the log.
Exception ignored in atexit callback: <bound method ExitHooks.history_save_handler of <montreal_forced_aligner.command_line.mfa.ExitHooks object at 0x0000016DD15D2410>>
Traceback (most recent call last):
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\command_line\mfa.py", line 97, in history_save_handler
    raise self.exception
  File "C:\Users\Ketaki\anaconda3\envs\aligner\Scripts\mfa-script.py", line 10, in <module>
    sys.exit(mfa_cli())
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\rich_click\rich_group.py", line 21, in main
    rv = super().main(*args, standalone_mode=False, **kwargs)
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\command_line\align.py", line 113, in align_corpus_cli
    aligner.align()
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\alignment\pretrained.py", line 412, in align
    super().align()
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\alignment\base.py", line 345, in align
    self.align_utterances()
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\alignment\mixins.py", line 436, in align_utterances
    for utterance, log_likelihood in run_kaldi_function(
  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\utils.py", line 753, in run_kaldi_function
    raise v
montreal_forced_aligner.exceptions.MultiprocessingError: MultiprocessingError:

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

  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\abc.py", line 85, in run
    yield from self._run()

  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\alignment\multiprocessing.py", line 955, in _run
    self.check_call(align_proc)

  File "C:\Users\Ketaki\anaconda3\envs\aligner\lib\site-packages\montreal_forced_aligner\abc.py", line 112, in check_call
    raise KaldiProcessingError([self.log_path])

montreal_forced_aligner.exceptions.KaldiProcessingError: KaldiProcessingError:

There were 1 job(s) with errors when running Kaldi binaries.
See the log files below for more information.
temp\temp_mfa\alignment\log\align.1.log`
mmcauliffe commented 1 year ago

Can you try passing a full path to the -t directory? Wondering if it might be due to pg_ctl parsing it as an absolute path vs relative path. If that still doesn't work, can you attach your pg_init_log_global.txt and pg_log_global.txt?

My guess for the second one is that it's a different bug, so if you could create another issue with the align.1.log file attached, that'd be great!

hailthedawn commented 1 year ago

Still getting the same issue even after passing the full path.

My pg_init_log_global.txt:

initdb: error: cannot be run as root
initdb: hint: Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

I don't seem to have a pg_log_global.txt - did it not init correctly?

mmcauliffe commented 1 year ago

Ah right yes, is it possible for you to create a non-root user to run MFA as in your container? https://docs.docker.com/engine/install/linux-postinstall/

hailthedawn commented 1 year ago

Hmm, will look into it but I think i'll try to run it locally since there's one fewer bug there. I did make a new issue about it (https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/issues/590).

abinayreddy commented 1 year ago

Still I am getting this error

cast_transcriptions/aligned_librispeech Traceback (most recent call last): File "/home/abinay/Mfa/bin/mfa", line 8, in sys.exit(mfa_cli()) File "/home/abinay/anaconda3/lib/python3.9/site-packages/click/core.py", line 1128, in call return self.main(*args, kwargs) File "/home/abinay/Mfa/lib/python3.9/site-packages/rich_click/rich_group.py", line 21, in main rv = super().main(args, standalone_mode=False, kwargs) File "/home/abinay/anaconda3/lib/python3.9/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/abinay/anaconda3/lib/python3.9/site-packages/click/core.py", line 1656, in invoke super().invoke(ctx) File "/home/abinay/anaconda3/lib/python3.9/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/abinay/anaconda3/lib/python3.9/site-packages/click/core.py", line 754, in invoke return __callback(args, kwargs) File "/home/abinay/anaconda3/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) File "/home/abinay/Mfa/lib/python3.9/site-packages/montreal_forced_aligner/command_line/mfa.py", line 127, in mfa_cli start_server() File "/home/abinay/Mfa/lib/python3.9/site-packages/montreal_forced_aligner/command_line/utils.py", line 359, in start_server subprocess.check_call( File "/home/abinay/anaconda3/lib/python3.9/subprocess.py", line 373, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['pg_ctl', '-D', PosixPath('/home/abinay/Documents/MFA/pg_mfa_global'), '-l', PosixPath('/home/abinay/Documents/MFA/pg_log_global.txt'), 'start']' returned non-zero exit status 1.

abinayreddy commented 1 year ago

Issue is resolved by installing dependencies first (conda install -c conda-forge python=3.8 kaldi sox librosa biopython praatio tqdm requests colorama pyyaml pynini openfst baumwelch ngram) provided in https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner, before installing Montreal-Forced-Aligner.

cartheee commented 1 year ago

I also encountered this problem which related to postgresql.But when I reboot my computer,the command(mfa validate C:/static/databases/Librispeech/19 "C:/static/mfa_data/my_corpus/english_us_arpa.dict" "C:/static/mfa_data/mycorpus/english_us_arpa.zip") magically returned to normal

hailthedawn commented 1 year ago

Rebooting didn't work for me. What was the transcript format that you used @cartheee ? I'm not too familiar with forced aligners. I removed punctuation except for apostrophes, and have everything in a single chunk of text (no newlines). Should I insert a newline after every pause in the audio? There's some silence in the audio as well between speakers - do I need to tag it somehow in my transcript? Not sure if that could be the issue.

NikitaKononov commented 1 year ago

Issue is resolved by installing dependencies first (conda install -c conda-forge python=3.8 kaldi sox librosa biopython praatio tqdm requests colorama pyyaml pynini openfst baumwelch ngram) provided in https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner, before installing Montreal-Forced-Aligner.

Good evening, why do you use postgres for dictionaries? it's enterprise level powerful database. it's source of bugs, complication of support and speed reduction in your case.

Classic python dictionaries have enough functionality for your task. If for some reason (it's hard to imagine such a thing) you need a database - take SQLite.

thiago-aixplain commented 1 year ago

A project I am working on uses MFA and require root user. SQLite as a dependency is generating a huge problem.