#5630 (GPTSoVits) zhitai@Mac GPT-SoVITS % python webui.pyRunning on local URL: http://0.0.0.0:9874ERROR: Exception in ASGI

117.181* Posted at: 1 day ago

(GPTSoVits) zhitai@Mac GPT-SoVITS % python webui.py
Running on local URL: http://0.0.0.0:9874
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 422, in run_asgi

result = await app(  # type: ignore[func-returns-value]

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 63, in call

return await self.app(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/applications.py", line 1163, in call

await super().__call__(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/applications.py", line 90, in call

await self.middleware_stack(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in
......
pt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call

await self.app(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/routing.py", line 660, in call

await self.middleware_stack(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/routing.py", line 2683, in app

await route.handle(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/routing.py", line 1266, in handle

await super().handle(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle

await self.app(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/routing.py", line 150, in app

await wrap_app_handling_exceptions(app, request)(scope, receive, send)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app

raise exc

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app

await app(scope, receive, sender)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/routing.py", line 136, in app

response = await f(request)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/routing.py", line 690, in app

raw_response = await run_endpoint_function(

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/fastapi/routing.py", line 346, in run_endpoint_function

return await run_in_threadpool(dependant.call, **values)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool

return await anyio.to_thread.run_sync(func)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/anyio/to_thread.py", line 63, in run_sync

return await get_async_backend().run_sync_in_worker_thread(

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2596, in run_sync_in_worker_thread

return await future

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1029, in run

result = context.run(func, *args)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/gradio/routes.py", line 432, in main

return templates.TemplateResponse(

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/templating.py", line 148, in TemplateResponse

template = self.get_template(name)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/starlette/templating.py", line 115, in get_template

return self.env.get_template(name)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/jinja2/environment.py", line 1016, in get_template

return self._load_template(name, globals)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/jinja2/environment.py", line 964, in _load_template

template = self.cache.get(cache_key)

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/jinja2/utils.py", line 477, in get

return self[key]

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/jinja2/utils.py", line 515, in getitem

rv = self._mapping[key]

TypeError: unhashable type: 'dict'
Traceback (most recent call last):
File "/Users/zhitai/GPT-SoVITS/webui.py", line 1975, in

app.queue().launch(  # concurrency_count=511, max_size=1022

File "/opt/miniconda3/envs/GPTSoVits/lib/python3.10/site-packages/gradio/blocks.py", line 2465, in launch

raise ValueError(

ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.

29 Replies

这是 GPT-SoVITS 自身服务启动错误,并非 pyVideoTrans 软件内部的问题。错误根源是 GPT-SoVITS 的 WebUI 无法在 localhost 正常访问(可能因网络环境或代理设置),且 gradio 的模板缓存出现类型错误。

要在 pyVideoTrans 中使用 GPT-SoVITS 配音渠道,必须启动的是 API 服务api.py),而不是 WebUI(webui.py)。请按照以下步骤操作:

  1. 正确启动 GPT-SoVITS API 服务
    在 GPT-SoVITS 项目目录下执行:

    python api.py

    默认端口为 9880,保持终端运行。

  2. 在 pyVideoTrans 中填写 API 地址
    打开 pyVideoTrans → 菜单 → TTS 设置 → GPT-SoVITS,填入:

    http://127.0.0.1:9880

    注意:切勿填写 WebUI 的 9874 端口或 0.0.0.0

  3. 检查版本兼容性
    如果启动 api.py 仍报错,请确保 GPT-SoVITS 的依赖(如 gradio, jinja2)版本与官方要求一致,必要时重装环境。

请查阅相关文档:

如果问题依旧,请提供 api.py 启动时的完整日志,以便进一步分析。

系统错误 (None):None
Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/soundfile.py", line 267, in

_snd = _ffi.dlopen('sndfile')

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/cffi/api.py", line 150, in dlopen

这是由于 macOS 系统缺少底层音频库 libsndfile 导致的。请通过 Homebrew 安装:

brew install libsndfile

安装完成后重新运行 uv run sp.py 即可。如果仍报错,请执行 brew reinstall libsndfile 并重启终端。

(GPTSoVits) zhitai@Mac GPT-SoVITS % python api.py
WARNING: 未指定SoVITS模型路径, fallback后当前值: GPT_SoVITS/pretrained_models/s2G488k.pth
WARNING: 未指定GPT模型路径, fallback后当前值: GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt
INFO: 未指定默认参考音频
INFO: 半精: False
INFO: 编码格式: wav
INFO: 数据类型: int16
INFO: Started server process [24241]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:9880 (Press CTRL+C to quit)

GPT-SoVITS API 服务已成功启动(端口 9880)。现在请在 pyVideoTrans 中完成对接:

  1. 打开 pyVideoTrans → 菜单 → TTS 设置 → GPT-SoVITS。
  2. API 地址填写:http://127.0.0.1:9880
  3. 若勾选了 api_v2? 选项,请确保与 GPT-SoVITS 版本匹配(一般新版用 v2,旧版不勾选)。
  4. 保存设置后,回到主界面选择 GPT-SoVITS 作为配音渠道,选择一个配音角色(如 default),即可测试配音。

如果仍有报错,请提供在 pyVideoTrans 中执行时的完整日志。

Response ended prematurely:
Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/models.py", line 820, in generate

yield from self.raw.stream(chunk_size, decode_content=True)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site

这是 GPT-SoVITS API 返回的请求被提前终止的错误。请按以下顺序排查:

  1. 参考音频未正确设置:GPT-SoVITS 需要一段参考音频(wav 格式,3-10 秒)放在 GPT-SoVITS 根目录下,并在 pyVideoTrans 的 菜单 → TTS 设置 → GPT-SoVITS 中填写参考音频文本(格式如 参考音频名.wav#音频里的文本)。缺少参考音频会导致请求被中断。
  2. 勾选了 api_v2 但 GPT-SoVITS 版本不符:如果你的 GPT-SoVITS 是旧版本(不支持 v2),请取消勾选 api_v2?。反之,新版本强制勾选。请确认版本对应。
  3. 请求超时:如果单次配音文本太长或 GPT-SoVITS 处理缓慢,可尝试降低并发数。在 pyVideoTrans 的 高级选项 → 字幕配音调整 中,将 并发配音线程数 设为 1,并适当增加 配音后暂停秒失败后重试次数
  4. 检查 GPT-SoVITS 终端日志:当 pyVideoTrans 发送请求时,GPT-SoVITS 终端会输出详细错误(如模型路径错误、显存不足等)。请观察 GPT-SoVITS 终端窗口是否有红色报错信息。
  5. 网络环回地址:确认 pyVideoTrans 中填写的 API 地址是 http://127.0.0.1:9880,不要用 0.0.0.0localhost

如果以上步骤仍无法解决,请提供 GPT-SoVITS 终端输出的完整错误信息以及 pyVideoTrans 的 logs/ 目录下最新日志(复制底部约 30 行)。

2026-07-05 16:49:46.030 python3[24562:260668] error messaging the mach port for IMKCFRunLoopWakeUpReliable
[ERROR] GPT-SoVITS ref_wav=''
返回错误:error_data='{"detail":"Not Found"}\nself.api_url=\'http://127.0.0.1:9880/tts\''

[ERROR] 试听配音时发生错误{"detail":"Not Found"}
self.api_url='http://127.0.0.1:9880/tts'
[ERROR]
第0条字幕配音失败,字幕文本:{'text': '你好啊我的朋友', 'role': 't.wav', 'filename': '/Users/zhitai/pyvideotrans/tmp/24562/1783241514.7252429-gptsovits.wav', 'tts_type': 11}
Response ended prematurely
Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/models.py", line 820, in generate

yield from self.raw.stream(chunk_size, decode_content=True)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/urllib3/response.py", line 1088, in stream

yield from self.read_chunked(amt, decode_content=decode_content)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/urllib3/response.py", line 12
......
nkedEncodingError: Response ended prematurely
[ERROR] 试听配音时发生错误Response ended prematurely
[ERROR] GPT-SoVITS ref_wav=''
返回错误:error_data='{"detail":"Not Found"}\nself.api_url=\'http://127.0.0.1:9880/tts\''

[ERROR] 试听配音时发生错误{"detail":"Not Found"}
self.api_url='http://127.0.0.1:9880/tts'
[ERROR] GPT-SoVITS ref_wav=''
返回错误:error_data='{"detail":"Not Found"}\nself.api_url=\'http://127.0.0.1:9880/tts\''

[ERROR] 试听配音时发生错误{"detail":"Not Found"}
self.api_url='http://127.0.0.1:9880/tts'
[ERROR]
第0条字幕配音失败,字幕文本:{'text': '你好啊我的朋友', 'role': 't.wav', 'filename': '/Users/zhitai/pyvideotrans/tmp/24562/1783241852.6274061-gptsovits.wav', 'tts_type': 11}
Response ended prematurely
Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/models.py", line 820, in generate

yield from self.raw.stream(chunk_size, decode_content=True)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/urllib3/response.py", line 1088, in stream

yield from self.read_chunked(amt, decode_content=decode_content)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/urllib3/response.py", line 1248, in read_chunked

self._update_chunk_length()

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/urllib3/response.py", line 1178, in _update_chunk_length

raise ProtocolError("Response ended prematurely") from None

urllib3.exceptions.ProtocolError: Response ended prematurely

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/videotrans/tts/_base.py", line 220, in _item_task

return self._run(data_item,idx)

File "/Users/zhitai/pyvideotrans/videotrans/tts/_gptsovits.py", line 77, in _run

response = requests.post(f"{self.api_url}", json=data,  timeout=3600,proxies={"https":"","http":""})

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/api.py", line 115, in post

return request("post", url, data=data, json=json, **kwargs)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/api.py", line 59, in request

return session.request(method=method, url=url, **kwargs)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/sessions.py", line 589, in request

resp = self.send(prep, **send_kwargs)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/sessions.py", line 746, in send

r.content

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/models.py", line 902, in content

self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/requests/models.py", line 822, in generate

raise ChunkedEncodingError(e)

requests.exceptions.ChunkedEncodingError: Response ended prematurely
[ERROR] 试听配音时发生错误Response ended prematurely

这是由于 GPT-SoVITS 的 API 版本与 pyVideoTrans 中配置的接口不匹配导致的。当前 GPT-SoVITS 使用的是 v2 API(默认路径并非 /tts),而 pyVideoTrans 发送请求到 /tts 路径则得到 404。

解决方法:

  1. 打开 pyVideoTrans → 菜单 → TTS 设置 → GPT-SoVITS
  2. 勾选 api_v2? 选项。
  3. 保存设置,重新尝试配音。

如果勾选后仍报错,请取消勾选 api_v2?(说明你的 GPT-SoVITS 是旧版 v1 接口),根据实际版本调整即可。

同时,日志中显示 ref_wav=''(参考音频为空),请按照之前说明,在 GPT-SoVITS 根目录放置一个 3-10 秒的 wav 参考音频,并在该设置页面填写参考音频文件名和对应的文本,例如:

myref.wav#音频里的说话内容

配置完成后再次测试。如果问题依旧,请提供 GPT-SoVITS 终端在 pyVideoTrans 发送请求时的输出信息。

系统错误 (None):None
Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/soundfile.py", line 267, in

_snd = _ffi.dlopen('sndfile')

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/cffi/api.py", line 150, in dlopen

该错误表明 macOS 系统缺少 libsndfile 音频库。执行以下命令安装:bashbrew install libsndfile安装完成后,重新启动 pyVideoTrans。如果已安装但仍报错,执行 brew reinstall libsndfile 并重启终端和软件。若问题依旧,请提供 brew list libsndfile 的输出和 macOS 版本。

(base) zhitai@Mac ~ % brew list libsndfile
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-cmp
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-concat
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-convert
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-deinterleave
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-info
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-interleave
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-metadata-get
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-metadata-set
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-play
/opt/homebrew/Cellar/libsndfile/1.2.2_1/bin/sndfile-salvage
/opt/homebrew/Cellar/libsndfile/1.2.2_1/include/ (2 files)
/opt/homebrew/Cellar/libsndfile/1.2.2_1/lib/libsndfile.1.0.37.dylib
/opt/homebrew/Cellar/libsndfile/1.2.2_1/lib/cmake/ (4 files)
/opt/homebrew/Cellar/libsndfile/1.2.2_1/lib/pkgconfig/sndfile.pc
/opt/homebrew/Cellar/libsndfile/1.2.2_1/lib/ (3 other files)
/opt/homebrew/Cellar/libsndfile/1.2.2_1/sbom.spdx.json
/opt/homebrew/Cellar/libsndfile/1.2.2_1/share/doc/ (16 files)
/opt/homebrew/Cellar/libsndfile/1.2.2_1/share/man/ (10 files)

macos 是15.7.3

你的 macOS 已正确安装 libsndfile(版本 1.2.2_1),但 Python 环境(.venv)中的 soundfile 模块无法自动定位该库。解决方法如下:

1. 设置动态库路径(临时方案)

在运行 pyVideoTrans 的终端中执行:

export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
uv run sp.py

如果有效,请将上面 export 命令添加到 ~/.zshrc 使其持久化。

2. 在 conda 环境中重新安装 soundfile(推荐)

你的 pyVideoTrans 使用了 .venv(基于 uv),但 libsndfile 是 brew 安装的。更稳定的做法是在当前 Python 环境下通过 conda 安装 libsndfile:

conda install -c conda-forge libsndfile

然后删除 .venv 并重新创建:

rm -rf .venv
uv sync
uv run sp.py

3. 检查 Python 位数是否匹配

运行以下命令确认 Python 是 64 位(与 Homebrew 的 libsndfile 一致):

python -c "import struct; print(struct.calcsize('P') * 8)"

若输出 64 则正常。

4. 其他验证

执行以下命令测试 soundfile 能否单独加载:

python -c "import soundfile; print('OK')"

若仍报错,请提供完整错误信息。

完成上述任一步骤后,重启 pyVideoTrans 即可。

(base) zhitai@Mac pyvideotrans % uv run sp.py
Uninstalled 1 package in 4ms
Installed 1 package in 2ms
1783242411:Loading resources...
1783242411:Loading main window...
1783242411:Initializing UI...
1783242411:SetupUI end...
1783242411:import recognition ...
1783242411:import tts ...
1783242412:import translate ...
1783242412:Get cache ...
1783242412:Set default value ...
1783242412:import voices list ...
1783242412:Set tts voice ...
1783242412:show main window ...
2026-07-05 17:06:52.038 python3[25213:291368] error messaging the mach port for IMKCFRunLoopWakeUpReliable
1783242412:Bind signal...
1783242412:set cursor...
1783242412:preload TTS win...
1783242412:preload STT win...
1783242412:preload translate srt win...
1783242412:end
[ERROR] 分离人声背景声失败,跳过 cannot load library '/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib': dlopen(/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.
......
library called 'sndfile'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/videotrans/task/only_one.py", line 46, in run

trk.recogn()

File "/Users/zhitai/pyvideotrans/videotrans/task/_stage_recogn.py", line 62, in recogn

raw_subtitles = run_recogn(

File "/Users/zhitai/pyvideotrans/videotrans/recognition/__init__.py", line 197, in run

_cls: Union[Type[BaseRecogn], None] = get_class(recogn_type, "recognition", _ID_NAME_DICT)

File "/Users/zhitai/pyvideotrans/videotrans/__init__.py", line 28, in get_class

module = importlib.import_module(f'videotrans.{provider_type}{_module_map.imp}', __name__)

File "/Users/zhitai/.local/share/uv/python/cpython-3.10.19-macos-aarch64-none/lib/python3.10/importlib/__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/Users/zhitai/pyvideotrans/videotrans/recognition/_whisper.py", line 13, in

from videotrans.process import openai_whisper, faster_whisper

File "/Users/zhitai/pyvideotrans/videotrans/process/__init__.py", line 2, in

from .tts_fun import qwen3tts_fun

File "/Users/zhitai/pyvideotrans/videotrans/process/tts_fun.py", line 9, in

import soundfile as sf

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/soundfile.py", line 276, in

_snd = _ffi.dlopen(_os.path.join(

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/cffi/api.py", line 150, in dlopen

lib, function_cache = _make_ffi_library(self, name, flags)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/cffi/api.py", line 834, in _make_ffi_library

backendlib = _load_backend_lib(backend, libname, flags)

File "/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/cffi/api.py", line 829, in _load_backend_lib

raise OSError(msg)

OSError: cannot load library '/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib': dlopen(/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib, 0x0002): tried: '/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib' (no such file), '/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib' (no such file). Additionally, ctypes.util.find_library() did not manage to locate a library called '/Users/zhitai/pyvideotrans/.venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib'

问题明确:你通过 Homebrew 安装了 libsndfile,但 Python 虚拟环境中的 soundfile 包找不到它(其捆绑库丢失)。按以下步骤任选一个即可。

方案一:设置环境变量(最快,无需重装)

在运行 pyVideoTrans 的终端中执行(需在 pyvideotrans 项目目录下):

export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
uv run sp.py

如果成功,将 export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH 添加到 ~/.zshrc 以持久化。

方案二:重建 soundfile(推荐,一劳永逸)

# 1. 激活虚拟环境
source .venv/bin/activate

# 2. 卸载当前 soundfile
uv pip uninstall soundfile

# 3. 重新安装,不使用捆绑库,强制使用系统库
uv pip install soundfile --no-binary soundfile

# 4. 验证
python -c "import soundfile; print('OK')"

若仍报错,执行:

# 创建符号链接(将 Homebrew 库链接到 soundfile 期望的位置)
mkdir -p .venv/lib/python3.10/site-packages/_soundfile_data
ln -s /opt/homebrew/lib/libsndfile.1.0.37.dylib .venv/lib/python3.10/site-packages/_soundfile_data/libsndfile.dylib

完成任一步骤后重新启动软件,分离人声背景声失败 的错误也会同时消失。

最后一步字幕配音嵌入时出错: Filter not found
Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/videotrans/task/_stage_assemble.py", line 423, in _subprocess

subprocess.run(

File "/Users/zhitai/.local/share/uv/python/cpython-3.10.19-macos-aarch64-none/lib/python3.10/subprocess.py", line

该错误 "Filter not found" 表示 macOS 系统上的 FFmpeg 缺少字幕处理所需的滤镜(如 subtitles, ass)。请按以下步骤解决:1. 重新安装完整版 FFmpeg(带 libass)brew uninstall ffmpe
brew install ffmpeg --with-libass如果 --with-libass 不可用,请改用:brew install ffmpeg libass安装后验证:ffmpeg -filters | grep subtitles若输出包含 subtitles 相关内容则正常。2. 确认 FFmpeg 可被 pyVideoTrans 找到软件会在启动时自动检测 PATH 中的 ffmpeg 和 ffprobe。运行以下命令确认路径:which ffmpe
ffmpeg -version3. 重启 pyVideoTrans完成上述步骤后,关闭并重新启动 pyVideoTrans,重新执行视频翻译任务。如果问题仍然存在,请提供 ffmpeg -version 的输出。

(base) zhitai@Mac pyvideotrans % ffmpeg -filters | grep subtitles
ffmpeg version 8.1.2 Copyright (c) 2000-2026 the FFmpeg developers
built with Apple clang version 17.0.0 (clang-1700.6.4.2)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/8.1.2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libsvtav1 --enable-libopus --enable-libx264 --enable-libmp3lame --enable-libdav1d --enable-libvmaf --enable-libvpx --enable-libx265 --enable-openssl --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 60. 26.102 / 60. 26.102
libavcodec 62. 28.102 / 62. 28.102
libavformat 62. 12.102 / 62. 12.102
libavdevice 62. 3.102 / 62. 3.102
libavfilter 11. 14.102 / 11. 14.102
libswscale 9. 5.102 / 9. 5.102
libswresample 6. 3.102 / 6. 3.102
(base) zhitai@Mac pyvideotrans %

你的 FFmpeg 是通过 Homebrew 安装的,但缺少字幕处理所需的 subtitles 滤镜(需要 libass 支持)。请按以下方法重新安装带字幕滤镜的 FFmpeg:1. 卸载当前 FFmpeg:brew uninstall ffmpeg2. 安装带 libass 的 FFmpeg:brew install ffmpeg --with-libass若提示选项无效(Homebrew 新版本可能已移除该选项),改用:brew install ffmpeg libass安装完成后,验证字幕滤镜是否可用:ffmpeg -filters | grep subtitles如果输出包含 subtitlesass 等滤镜名称,则问题解决。3. 重启 pyVideoTrans,重新执行视频翻译任务。如果仍提示 "Filter not found",可在视频翻译界面选择不嵌入字幕(字幕类型选“不嵌入”)作为临时绕过方案,但会丢失字幕显示。请查阅相关文档:

最后一步字幕配音嵌入时出错: Filter not found
Traceback (most recent call last):
File "/Users/zhitai/pyvideotrans/videotrans/task/_stage_assemble.py", line 423, in _subprocess

subprocess.run(

File "/Users/zhitai/.local/share/uv/python/cpython-3.10.19-macos-aarch64-none/lib/python3.10/subprocess.py", line

问题仍然是 FFmpeg 缺少 subtitles 滤镜(需要 libass)。你的 FFmpeg 配置中未包含 --enable-libass。请按以下步骤彻底修复:步骤 1:检查并安装 libassbrew list libass 2>/dev/null || brew install libass步骤 2:卸载当前 ffmpegbrew uninstall ffmpeg步骤 3:重新安装 ffmpeg(自动链接已安装的 libass)brew install ffmpeg步骤 4:验证是否包含字幕滤镜ffmpeg -filters | grep subtitles正常应输出类似:... subtitles ... ...若仍有错误,尝试清理缓存并强制重建:brew cleanup
brew reinstall ffmpeg步骤 5:重启 pyVideoTrans若修复后仍报错,请提供 ffmpeg -version 的完整输出(包括 configuration 行)。临时替代方案如果你的视频翻译任务不强制要求硬字幕,可在 pyVideoTrans 主界面选择“嵌入软字幕”或“不嵌入字幕”,跳过字幕滤镜需求,先完成翻译并收听配音效果。

(base) zhitai@Mac ~ % ffmpeg -version
ffmpeg version 8.1.2 Copyright (c) 2000-2026 the FFmpeg developers
built with Apple clang version 17.0.0 (clang-1700.6.4.2)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/8.1.2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libsvtav1 --enable-libopus --enable-libx264 --enable-libmp3lame --enable-libdav1d --enable-libvmaf --enable-libvpx --enable-libx265 --enable-openssl --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 60. 26.102 / 60. 26.102
libavcodec 62. 28.102 / 62. 28.102
libavformat 62. 12.102 / 62. 12.102
libavdevice 62. 3.102 / 62. 3.102
libavfilter 11. 14.102 / 11. 14.102
libswscale 9. 5.102 / 9. 5.102
libswresample 6. 3.102 / 6. 3.102

Exiting with exit code 0

你的 FFmpeg 仍缺少 libass 支持。Homebrew 的新版 ffmpeg 公式默认移除了 --with-libass 选项,需要手动启用。请执行以下命令重新安装:1. 先卸载现有 ffmpeg:brew uninstall --ignore-dependencies ffmpeg2. 编辑 ffmpeg 公式以启用 libass:brew edit ffmpeg在打开的编辑器中,找到类似 --enable-libvpx 的行,在附近的 args << "--enable-libvpx" 后面添加一行:args << "--enable-libass"保存并退出编辑器。3. 重新安装 ffmpeg(会使用修改后的配置):brew install ffmpeg4. 等待编译完成后验证:ffmpeg -filters | grep subtitles应输出带有 subtitles 滤镜的行。如果上述修改公式的方法过于复杂,可以改用以下第三方仓库(推荐,更简单):brew tap homebrew-ffmpeg/ffmpegbrew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-libass安装后同样用 ffmpeg -filters | grep subtitles 验证。完成任一步骤后,重启 pyVideoTrans 即可使用硬字幕。若仍失败,请在软件中选择软字幕(可关闭的字幕轨道)绕过此问题。

(base) zhitai@Mac ~ % ffmpeg -filters | grep subtitles
ffmpeg version 8.1.2 Copyright (c) 2000-2026 the FFmpeg developers
built with Apple clang version 17.0.0 (clang-1700.6.4.2)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/8.1.2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libsvtav1 --enable-libopus --enable-libx264 --enable-libmp3lame --enable-libdav1d --enable-libvmaf --enable-libvpx --enable-libx265 --enable-openssl --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 60. 26.102 / 60. 26.102
libavcodec 62. 28.102 / 62. 28.102
libavformat 62. 12.102 / 62. 12.102
libavdevice 62. 3.102 / 62. 3.102
libavfilter 11. 14.102 / 11. 14.102
libswscale 9. 5.102 / 9. 5.102
libswresample 6. 3.102 / 6. 3.102

你的 FFmpeg 配置中仍然缺少 libass(未显示 --enable-libass),因此 subtitles 滤镜不可用。请按以下方法解决:

方案一:使用第三方 ffmpeg 仓库(推荐,一步到位)

# 添加支持 libass 的 tap
brew tap homebrew-ffmpeg/ffmpeg

# 安装带有 libass 的 ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-libass

安装后验证:

ffmpeg -filters | grep subtitles

如果输出中包含了 subtitlesass,则问题解决。

方案二:临时绕过(无需重新编译)

在 pyVideoTrans 主界面,将字幕嵌入类型改为 嵌入软字幕(播放器可开关),或 不嵌入字幕(仅替换声音)。软字幕使用内置轨道形式,不依赖 subtitles 滤镜,可正常合成。

完成任一步骤后重启软件,再次执行视频翻译即可。

(base) zhitai@Mac ~ % brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-libass
==> Auto-updating Homebrew...
Adjust how often this is run with $HOMEBREW_AUTO_UPDATE_SECS or disable with
$HOMEBREW_NO_AUTO_UPDATE=1. Hide these hints with $HOMEBREW_NO_ENV_HINTS=1 (see man brew).
Usage: brew install [options] formula|cask [...]

Install a formula or cask. Additional options specific to a formula may be
appended to the command.

Unless $HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK is set, brew upgrade or brew
reinstall will be run for outdated dependents and dependents with broken
linkage, respectively.

Unless $HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will then be run
for the installed formulae or, every 30 days, for all formulae.

Unless $HOMEBREW_NO_INSTALL_UPGRADE is set, brew install formula will
upgrade formula if it is already installed but outdated.

-d, --debug If brewing fails, open an interactive

......
dumping support

  --with-rubberband            ffmpeg:
                                   Enable rubberband library
  --with-two-lame              ffmpeg:
                                   Enable TwoLAME, an optimized MPEG Audio
                               Layer 2 (MP2) encoder
  --with-webp                  ffmpeg:
                                   Enable using libwebp to encode WEBP
                               images
  --with-whisper-cpp           ffmpeg:
                                   Enable OpenAI's Whisper speech
                               recognition model
  --with-xvid                  ffmpeg:
                                   Enable Xvid
  --with-zeromq                ffmpeg:
                                   Enable using libzeromq to receive cmds
                               sent through a libzeromq client
  --with-zimg                  ffmpeg:
                                   Enable z.lib zimg library
  --with-srt                   ffmpeg:
                                   Enable SRT library
  --with-libvmaf               ffmpeg:
                                   Enable libvmaf scoring library
  --with-libxml2               ffmpeg:
                                   Enable libxml2 library
  --with-libzvbi               ffmpeg:
                                   Enable decoding of DVB teletext pages and
                               DVB teletext subtitles
  --with-aribb24               ffmpeg:
                                   Build with aribb24 support
  --with-libbluray             ffmpeg:
                                   Build with libbluray support
  --with-libbs2b               ffmpeg:
                                   Build with libbs2b support
  --with-libcaca               ffmpeg:
                                   Build with libcaca support
  --with-libdvdnav             ffmpeg:
                                   Build with libdvdnav support
  --with-libdvdread            ffmpeg:
                                   Build with libdvdread support
  --with-libgsm                ffmpeg:
                                   Build with libgsm support
  --with-libtensorflow         ffmpeg:
                                   Build with libtensorflow support
  --with-openssl@3             ffmpeg:
                                   Build with openssl@3 support
  --with-speex                 ffmpeg:
                                   Build with speex support

-q, --quiet Make some output more quiet.
-h, --help Show this message.
Error: invalid option: --with-libass
Did you mean? with-librist

           with-librsvg
           with-libssh
           with-libbs2b
           with-libcaca
           with-libgsm

你的 FFmpeg 仍缺少 libass(该仓库已不支持 --with-libass 选项)。请采用以下任一方法解决:临时方案(最快):在 pyVideoTrans 主界面,将字幕嵌入类型改为 嵌入软字幕不嵌入字幕,即可跳过字幕滤镜依赖,正常生成视频并保留配音。永久方案:下载已包含 libass 的静态编译版 FFmpeg1. 访问 https://evermeet.cx/ffmpeg/ 下载 ffmpeg 和 ffprobe(均为静态版,已内置 libass)。2. 将下载的两个文件复制到 /usr/local/bin 并赋予可执行权限:sudo cp ~/Downloads/ffmpeg /usr/local/bin/
sudo cp ~/Downloads/ffprobe /usr/local/bin/
sudo chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe3. 验证:ffmpeg -filters | grep subtitles应输出包含 subtitles 滤镜的行。4. 重启 pyVideoTrans。若仍无法解决问题,请提供下载链接并截图 ffmpeg -filters | grep subtitles 的输出。

[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-6.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-7.wav'
[WARNING] 参考音频大于10s,需截断:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-11.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-13.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-19.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-21.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-22.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-23.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-24.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-26.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-27.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-28.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-29.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-30.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-31.wav'
[WARNING] 参考音频小于3s,无法克隆,跳过:ref_wav='/Users/zhitai/pyvideotrans/tmp/35123/6e09828a76/clone-32.wav'

这是语音识别生成的字幕时长不符合克隆要求(需 3-10 秒)导致的。请按以下步骤调整:打开 pyVideoTrans → 菜单 → 工具 → 高级选项 → 语音识别参数。将 最长语音持续(秒) 设为 10。将 最短语音持续(毫秒) 设为 3000。勾选 合并过短字幕到邻近。勾选 Whisper预分割音频(若未选中)。务必确保 未勾选 LLM重新断句(克隆模式下禁用)。保存设置后重新执行视频翻译任务,所有参考音频片段会自动控制在 3-10 秒内,克隆即可正常进行。请查阅相关文档:语音克隆配置指南高级选项参数详解

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update. Dondate: ko-fi.com/jianchang512

Related resource