zh-plus / openlrc

Transcribe and translate voice into LRC file using Whisper and LLMs (GPT, Claude, et,al). 使用whisper和LLM(GPT,Claude等)来转录、翻译你的音频为字幕文件。
https://zh-plus.github.io/openlrc/
MIT License
459 stars 33 forks source link

lrcer.run执行报错 #28

Closed Origin1699 closed 9 months ago

Origin1699 commented 9 months ago

test.py 代码如下

from openlrc import LRCer
lrcer = LRCer()
lrcer.run('./data/1.wav', target_lang='zh-cn')

执行报错内容如下

D:\test>python test.py
C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\df\io.py:9: UserWarning: 'torchaudio.backend.common.AudioMetaData' has been moved to 'torchaudio.AudioMetaData'. Please update the import path.
  from torchaudio.backend.common import AudioMetaData
 [2024-01-23 22:06:02] INFO     [MainThread] Default context config not found: Context(background=, audio_type=Anime, description_map={}), using default context.
 [2024-01-23 22:06:02] INFO     [MainThread] Loudness normalizing...
C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\df\io.py:9: UserWarning: 'torchaudio.backend.common.AudioMetaData' has been moved to 'torchaudio.AudioMetaData'. Please update the import path.
  from torchaudio.backend.common import AudioMetaData
 [2024-01-23 22:06:07] INFO     [MainThread] Default context config not found: Context(background=, audio_type=Anime, description_map={}), using default context.
 [2024-01-23 22:06:07] INFO     [MainThread] Loudness normalizing...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 120, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 129, in _main
    prepare(preparation_data)
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 240, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 291, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "D:\test\test.py", line 18, in <module>
    lrcer.run('./data/1.wav', target_lang='zh-cn')
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\openlrc.py", line 231, in run
    audio_paths = self.pre_process(paths, noise_suppress=noise_suppress)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\openlrc.py", line 289, in pre_process
    paths = preprocessor.run(noise_suppress)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 139, in run
    ln_paths: list[Path] = self.loudness_normalization(ns_paths)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 106, in loudness_normalization
    results = [executor.submit(loudness_norm_single, *arg) for arg in args]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 106, in <listcomp>
    results = [executor.submit(loudness_norm_single, *arg) for arg in args]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 782, in submit
    self._adjust_process_count()
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 741, in _adjust_process_count
    self._spawn_process()
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 759, in _spawn_process
    p.start()
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
                  ^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\context.py", line 336, in _Popen
    return Popen(process_obj)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 158, in get_preparation_data
    _check_not_importing_main()
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 138, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
 [2024-01-23 22:06:07] ERROR    [MainThread] Loudness normalization failed, exception: A process in the process pool was terminated abruptly while the future was running or pending.
Traceback (most recent call last):
  File "D:\test\test.py", line 18, in <module>
    lrcer.run('./data/1.wav', target_lang='zh-cn')
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\openlrc.py", line 231, in run
    audio_paths = self.pre_process(paths, noise_suppress=noise_suppress)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\openlrc.py", line 289, in pre_process
    paths = preprocessor.run(noise_suppress)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 139, in run
    ln_paths: list[Path] = self.loudness_normalization(ns_paths)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\gyx\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 114, in loudness_normalization
    raise exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
zh-plus commented 9 months ago

Check the solution here: https://github.com/zh-plus/openlrc/discussions/15#discussioncomment-7249044