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
429 stars 28 forks source link

音频预处理阶段出错 Runtime exception during preprocess #17

Closed lostkira closed 10 months ago

lostkira commented 10 months ago

Dependecies all installed according to the documents

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 120, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 129, in _main
    prepare(preparation_data)
  File "C:\Users\ezrealc\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\ezrealc\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 "C:\Users\ezrealc\Desktop\openlrc\openlrc-run.py", line 11, in <module>
    lrcer.run("example.mp3", target_lang='zh-cn')
  File "C:\Users\ezrealc\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\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\openlrc.py", line 289, in pre_process
    paths = preprocessor.run(noise_suppress)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 131, in run
    ln_paths: list[Path] = self.loudness_normalization(ns_paths)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 106, in loudness_normalization
    _ = [executor.submit(loudness_norm_single, *arg) for arg in args]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 106, in <listcomp>
    _ = [executor.submit(loudness_norm_single, *arg) for arg in args]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 787, in submit
    self._adjust_process_count()
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 746, in _adjust_process_count
    self._spawn_process()
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 764, in _spawn_process
    p.start()
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
                  ^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\context.py", line 336, in _Popen
    return Popen(process_obj)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\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\ezrealc\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 158, in get_preparation_data
    _check_not_importing_main()
  File "C:\Users\ezrealc\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.
Traceback (most recent call last):
  File "C:\Users\ezrealc\Desktop\openlrc\openlrc-run.py", line 11, in <module>
    lrcer.run("example.mp3", target_lang='zh-cn')
  File "C:\Users\ezrealc\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\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\openlrc.py", line 289, in pre_process
    paths = preprocessor.run(noise_suppress)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 136, in run
    ln_path = ln_path.rename(ln_path.parent / f'{audio_name}_preprocessed.wav')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 1175, in rename
    os.rename(self, target)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。: 'preprocessed\\example_ln.wav' -> 'preprocessed\\example_preprocessed.wav'
zh-plus commented 10 months ago

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

lostkira commented 10 months ago

wrapping invocation code fixed issue 1, but the second issue still exists

Traceback (most recent call last):
  File "C:\Users\ezrealc\Desktop\openlrc\openlrc-run.py", line 11, in <module>
    lrcer.run("example.mp3", target_lang='zh-cn')
  File "C:\Users\ezrealc\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\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\openlrc.py", line 289, in pre_process
    paths = preprocessor.run(noise_suppress)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\site-packages\openlrc\preprocess.py", line 136, in run
    ln_path = ln_path.rename(ln_path.parent / f'{audio_name}_preprocessed.wav')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ezrealc\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 1175, in rename
    os.rename(self, target)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。: 'preprocessed\\example_ln.wav' -> 'preprocessed\\example_preprocessed.wav'
zh-plus commented 10 months ago

Which version of openlrc are you using? I can't reproduce this error. Try to install the latest version from github using: pip install git+https://github.com/zh-plus/Open-Lyrics

lostkira commented 10 months ago

I use python 3.11 and the latest version of openlrc in pypi. Now I run pip install git+https://github.com/zh-plus/Open-Lyrics --force-reinstall, issue still exists. However it installed pydantic=2.4.2 and suggests fastapi 0.97.0 requires pydantic!=1.8,!=1.8.1,<2.0.0,>=1.7.4, so i tried pydantic==1.10.13, dont work. Maybe let me try it in your current environment? just pip freeze it

accelerate==0.20.3
aiofiles==23.1.0
aiohttp==3.8.6
aiosignal==1.3.1
altair==5.0.1
annotated-types==0.6.0
antlr4-python3-runtime==4.9.3
anyio==3.7.1
appdirs==1.4.4
async-timeout==4.0.3
attrs==23.1.0
audioread==3.0.1
av==10.0.0
blis==0.7.11
catalogue==2.0.10
certifi==2023.7.22
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
cloudpathlib==0.16.0
colorama==0.4.6
coloredlogs==15.0.1
colorlog==6.7.0
confection==0.1.3
contourpy==1.1.0
cpm-kernels==1.0.11
ctranslate2==3.20.0
cycler==0.11.0
cymem==2.0.8
DeepFilterLib==0.5.6
DeepFilterNet==0.5.6
distro==1.8.0
fastapi==0.97.0
faster-whisper==0.8.0
ffmpeg-normalize==1.27.7
ffmpeg-progress-yield==0.7.8
ffmpeg-python==0.2.0
ffmpy==0.3.0
filelock==3.13.1
filetype==1.2.0
flatbuffers==23.5.26
fonttools==4.40.0
frozenlist==1.4.0
fsspec==2023.10.0
future==0.18.3
ghp-import==2.1.0
gradio==3.35.2
gradio_client==0.2.7
h11==0.14.0
httpcore==1.0.1
httpx==0.25.1
huggingface-hub==0.19.0
humanfriendly==10.0
idna==3.4
jaconvV2==0.4
Jinja2==3.1.2
jsonschema==4.17.3
kiwisolver==1.4.4
langcodes==3.3.0
language-data==1.1
latex2mathml==3.76.0
lingua-language-detector==1.3.4
linkify-it-py==2.0.2
loguru==0.7.2
marisa-trie==0.7.8
Markdown==3.3.7
markdown-it-py==2.2.0
MarkupSafe==2.1.3
matplotlib==3.7.1
mdit-py-plugins==0.3.3
mdtex2html==1.2.0
mdurl==0.1.2
mergedeep==1.3.4
mkdocs==1.4.3
mkdocs-material==9.1.18
mkdocs-material-extensions==1.1.1
mpmath==1.3.0
multidict==6.0.4
murmurhash==1.0.10
networkx==3.2.1
numpy==1.26.1
omegaconf==2.3.0
onnxruntime==1.16.2
openai==1.2.2
openlrc @ git+https://github.com/zh-plus/Open-Lyrics@bf7f02874ed93c997c1b451e49925c9de0cc2073
orjson==3.9.1
packaging==23.2
pandas==2.1.2
Pillow==10.1.0
preshed==3.0.9
protobuf==4.25.0
psutil==5.9.5
punctuators==0.0.5
pycparser==2.21
pydantic==1.10.13
pydantic_core==2.0.1
pydub==0.25.1
Pygments==2.15.1
pymdown-extensions==10.0.1
pyparsing==3.0.9
pyreadline3==3.4.1
pyrsistent==0.19.3
pysbd==0.3.4
python-dateutil==2.8.2
python-multipart==0.0.6
pytz==2023.3.post1
pywin32==306
PyYAML==6.0.1
pyyaml_env_tag==0.1
regex==2023.10.3
requests==2.31.0
semantic-version==2.10.0
sentencepiece==0.1.99
six==1.16.0
smart-open==6.4.0
sniffio==1.3.0
soundfile==0.12.1
spacy==3.7.2
spacy-legacy==3.0.12
spacy-loggers==1.0.5
srsly==2.4.8
starlette==0.27.0
sympy==1.12
thinc==8.2.1
tiktoken==0.3.3
tokenizers==0.13.3
toolz==0.12.0
torch==2.0.0
torchaudio==2.0.1
torchvision==0.15.1
tqdm==4.66.1
transformers==4.27.1
typer==0.9.0
typing_extensions==4.8.0
tzdata==2023.3
uc-micro-py==1.0.2
urllib3==2.0.7
uvicorn==0.22.0
wasabi==1.1.2
watchdog==3.0.0
weasel==0.3.4
websockets==11.0.3
win32-setctime==1.1.0
yarl==1.9.2
zhconv==1.4.3
zh-plus commented 10 months ago

Here is my env:

accelerate==0.21.0
aiohttp==3.8.4
aiosignal==1.3.1
antlr4-python3-runtime==4.9.3
anyio==3.7.1
appdirs==1.4.4
async-timeout==4.0.2
attrs==23.1.0
audioread==3.0.0
av==10.0.0
blis==0.7.9
catalogue==2.0.8
certifi==2023.5.7
cffi==1.16.0
charset-normalizer==3.2.0
click==8.1.4
colorama==0.4.6
coloredlogs==15.0.1
colorlog==6.7.0
confection==0.1.0
ctranslate2==3.17.1
cymem==2.0.7
DeepFilterLib==0.5.6
DeepFilterNet==0.5.6
deepl==1.15.0
diskcache==5.6.3
distro==1.8.0
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.6.0/en_core_web_sm-3.6.0-py3-none-any.whl#sha256=83276fc78a70045627144786b52e1f2728ad5e29e5e43916ec37ea9c26a11212
es-core-news-sm @ https://github.com/explosion/spacy-models/releases/download/es_core_news_sm-3.6.0/es_core_news_sm-3.6.0-py3-none-any.whl#sha256=917d0b6359b27b222ccd616c47b43ee951f05da7402fdccce99364a465fa95d6
exceptiongroup==1.1.3
faster-whisper==0.8.0
ffmpeg-normalize==1.27.5
ffmpeg-progress-yield==0.7.8
ffmpeg-python==0.2.0
filelock==3.12.2
filetype==1.2.0
FLAML==2.1.1
flatbuffers==23.5.26
frozenlist==1.3.3
fsspec==2023.6.0
future==0.18.3
h11==0.14.0
httpcore==1.0.1
httpx==0.25.1
huggingface-hub==0.16.4
humanfriendly==10.0
idna==3.4
ja-core-news-sm @ https://github.com/explosion/spacy-models/releases/download/ja_core_news_sm-3.6.0/ja_core_news_sm-3.6.0-py3-none-any.whl#sha256=52bcd3df687c9ae1b55806b4d9e49b517d419d0633951a2d8806c8fa2eef498a
jaconvV2==0.4
Jinja2==3.1.2
langcodes==3.3.0
language-data==1.1
lingua-language-detector==1.3.2
loguru==0.7.0
marisa-trie==0.7.8
MarkupSafe==2.1.3
mpmath==1.3.0
multidict==6.0.4
murmurhash==1.0.9
networkx==3.1
numpy==1.24.4
omegaconf==2.3.0
onnxruntime==1.15.1
openai==1.1.1
packaging==23.1
pandas==2.0.3
pathy==0.10.2
Pillow==9.3.0
preshed==3.0.8
protobuf==4.23.4
psutil==5.9.5
pt-core-news-sm @ https://github.com/explosion/spacy-models/releases/download/pt_core_news_sm-3.6.0/pt_core_news_sm-3.6.0-py3-none-any.whl#sha256=61a9193dd1cb7ae1a65a85f7c98f4b14077a8bd3dc34a486aa620a54b353a1d9
punctuators==0.0.5
pyautogen==0.1.11
pycparser==2.21
pydantic==1.10.11
pyreadline3==3.4.1
pysbd==0.3.4
python-dateutil==2.8.2
python-dotenv==1.0.0
pytz==2023.3
PyYAML==6.0
regex==2022.10.31
requests==2.31.0
safetensors==0.3.1
sentencepiece==0.1.99
six==1.16.0
smart-open==6.3.0
sniffio==1.3.0
soundfile==0.12.1
spacy==3.6.0
spacy-legacy==3.0.12
spacy-loggers==1.0.4
spacy-pkuseg==0.0.33
srsly==2.4.6
SudachiDict-core==20230110
SudachiPy==0.6.7
sympy==1.12
termcolor==2.3.0
thinc==8.1.10
tiktoken==0.3.3
tokenizers==0.13.3
torch==2.0.1+cu118
torchaudio==2.0.2+cu118
torchvision==0.15.2+cu118
tqdm==4.65.0
transformers==4.30.2
typer==0.9.0
typing_extensions==4.7.1
tzdata==2023.3
urllib3==2.0.3
wasabi==1.1.2
win32-setctime==1.1.0
yarl==1.9.2
zh-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.6.0/zh_core_web_sm-3.6.0-py3-none-any.whl#sha256=252fea460a4e63b0d5d81ee2e2339dc69fb21b6b17e2e5c35df75f5cb6ca33d7
zhconv==1.4.3

Can you share your 'example.wav'? I can try to process the same file.