Consider forking and maintaining pyctcdecode or switch to torchaudio.models.decoder

这个报错通常发生在同时安装 transformers[torch-speech] 和 pyannote-audio==4.0.0 时,原因是 pyctcdecode 限制 numpy=2.0 。优先排查 numpy 版本,或改用维护者提供的

快速结论:这个报错通常发生在同时安装 transformers[torch-speech]pyannote-audio==4.0.0 时,原因是 pyctcdecode 限制 numpy<2.0.0,而新版 pyannote 需要 numpy>=2.0。优先排查 numpy 版本,或改用维护者提供的 pyctcdecode fork。

适用环境:Hugging Face Transformers 4.56.2、pyannote-audio 4.0.0、pyctcdecode 0.5.0、numpy 2.0 及以上、uv 包管理器。Issue 中未明确给出 Python、CUDA、显卡版本。

最快修复方案:暂无确认的一步修复方案。可优先尝试安装 Issue 作者提供的 pyctcdecode fork(https://github.com/mediacatch/pyctcdecode),该 fork 在保留旧版 index 接口的同时移除了 numpy<2.0.0 限制。

注意事项:该 fork 是个人维护,未合并到上游,可能不适合生产环境。官方计划迁移到 torchaudio.models.decoder,但尚未完成,且迁移后 attrs.json 中的 pyctcdecode 参数无法完全对应,可能导致解码质量下降。

问题场景

用户在全新虚拟环境中通过 uv 安装 transformers[torch-speech]==4.56.2pyannote-audio==4.0.0 时,依赖解析器报告两个包无法同时安装。该冲突也影响任何需要同时使用新版 pyannote 语音库和 Transformers ASR pipeline(如 Wav2Vec2ProcessorWithLM)的项目。

报错原文

  × No solution found when resolving dependencies:
  ╰─▶ Because transformers[torch-speech]==4.56.2 depends on pyctcdecode>=0.4.0 and pyctcdecode>=0.4.0 depends on numpy>=1.15.0,=1.15.0,=2.0 and only pyannote-core=6.0.1 depends on numpy>=2.0.
      And because pyannote-audio==4.0.0 depends on pyannote-core>=6.0.1, we can conclude that pyannote-audio==4.0.0 depends on numpy>=2.0.
      And because we know from (1) that transformers[torch-speech]==4.56.2 depends on numpy>=1.15.0,<2.0.0, we can conclude that pyannote-audio==4.0.0 and transformers[torch-speech]==4.56.2 are incompatible.
      And because you require transformers[torch-speech]==4.56.2 and pyannote-audio==4.0.0, we can conclude that your requirements are unsatisfiable.

原因分析

可能原因有两个,且相互叠加:

  • pyctcdecode 项目已基本停止维护,最新发布的 0.5.0 版本(2023 年 1 月)仍将依赖限制为 numpy<2.0.0,即使社区提交了 numpy 2.0 支持 PR(kensho-technologies/pyctcdecode#116),也长期未被合并。
  • pyctcdecode 主分支最近一次提交将解码器输出格式从 tuple 改为 dataclass,与 Transformers 现有的 ASR pipeline 代码不兼容。

环境排查

celebrityanime
celebrityanime
文章: 18306

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注