#5924 Whisper.net recognition failed: Method not found: 'System.TimeSpan System.TimeSpan.FromMilliseconds(Int64)'. at Whispe

240e:39c* Posted at: 5 hours ago

Whisper.net recognition failed: Method not found: 'System.TimeSpan System.TimeSpan.FromMilliseconds(Int64)'.
at Whisper.net.WhisperProcessor.OnNewSegment(IntPtr state)
at Whisper.net.WhisperProcessor.OnNewSegmentStatic(IntPtr ctx, IntPtr state, Int32 nNew, IntPtr userData)
at Whisper.net.Internals.Native.Implementations.LibraryImportLibWhisper.whisper_full_with_state(IntPtr context, IntPtr state, WhisperFullParams parameters, IntPtr samples, Int32 nSamples)
at Whisper.net.WhisperProcessor.Process(ReadOnlySpan`1 samples)
at Whisper.net.WhisperProcessor.Process(Single[] samples)
at Whisper.net.WhisperProcessor.Process(Stream waveStream)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
Traceback (most recent call last):
File "videotrans\recognition\_whispernet.py", line 269, in _exec
System.MissingMethodException: Method not found: 'System.TimeSpan System.TimeSpan.FromMilliseconds(Int64)'.
at Whisper.net.WhisperProcessor.OnNewSegment(IntPtr state)
at Whisper.net.WhisperProcessor.OnNewSegmentStatic(IntPtr ctx, IntPtr state, Int32 nNew, IntPtr userData)
at Whisper.net.Internals.Native.Implementations.LibraryImportLibWhisper.whisper_full_with_state(IntPtr context, IntPtr state, WhisperFullParams parameters, IntPtr samples, Int32 nSamples)
at Whisper.net.WhisperProcessor.Process(ReadOnlySpan`1 samples)
at Whisper.net.WhisperProcessor.Process(Single[] samples)
at Whisper.net.WhisperProcessor.Process(Stream waveStream)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "videotrans\task\only_one.py", line 47, in run
File "videotrans\task\_stage_recogn.py", line 62, in recogn
File "videotrans\recognition\__init__.py", line 205, in run
File "videotrans\recognition\_base.py", line 91, in run
File "videotrans\recognition\_whispernet.py", line 285, in _exec
videotrans.configure.excepts.SpeechToTextError: Whisper.net recognition failed: Method not found: 'System.TimeSpan System.TimeSpan.FromMilliseconds(Int64)'.
at Whisper.net.WhisperProcessor.OnNewSegment(IntPtr state)
at Whisper.net.WhisperProcessor.OnNewSegmentStatic(IntPtr ctx, IntPtr state, Int32 nNew, IntPtr userData)
at Whisper.net.Internals.Native.Implementations.LibraryImportLibWhisper.whisper_full_with_state(IntPtr context, IntPtr state, WhisperFullParams parameters, IntPtr samples, Int32 nSamples)
at Whisper.net.WhisperProcessor.Process(ReadOnlySpan`1 samples)
at Whisper.net.WhisperProcessor.Process(Single[] samples)
at Whisper.net.WhisperProcessor.Process(Stream waveStream)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

cfg=[TaskCfgVTT]当前工作模式: 翻译视频或音频 单视频模式
原始输入文件名: G:/1.mp4,
输出结果保存到文件夹: G:/迅雷下载/修复/1-mp4,
临时文件夹: F:/pyvideotrans/tmp/36252/5c7d88d507
已选 清理已存在
未选 启用CUDA加速
已选 降噪
已选 识别说话人,最大说话人数量3
语音识别:Whisper.NET, model_name: ggml-large-v3.bin, 发音语言: 英语, 断句方式:默认断句
翻译渠道:兼容AI/本地模型,原始语言:英语,目标语言:简体中文, 已选 发送完整字幕
配音渠道:Qwen3-TTS(本地内置), 角色:clone, 配音语言:简体中文, 未选 二次语音识别
音量:+0%, 语速:+0%, 已选 音频加速, 未选 视频慢速
字幕: 嵌入硬字幕
已选 分离人声与背景声,存在分离后的纯净人声文件,存在分离后的背景声音文件
代理地址:


=
system:Windows-10-10.0.26100-SP0
version:v4.06
frozen:True
language:zh
root_dir:F:/pyvideotrans

3 Replies

此错误是由于 Whisper.NET 的本地依赖库(.NET 运行时)版本与软件所需的版本不匹配导致的。System.TimeSpan.FromMilliseconds(Int64) 方法可能仅在较新的 .NET 运行时中存在(如 .NET 8+),而你的系统中运行的 .NET 运行时版本过低(例如 .NET 6 或更早),导致在调用时找不到该方法。

解决方案

  1. 安装最新 .NET 运行时
    前往 dotnet.microsoft.com 下载并安装 .NET 8.0 或 .NET 9.0 运行时(Runtime,非 SDK,选择 Windows x64 版本)。安装后重启软件。
  2. 使用其他语音识别渠道
    Whisper.NET 仅用于 AMD 显卡的 Vulkan 加速场景。如果你没有 AMD 显卡或不需要该渠道,建议直接切换为 faster-whisper(本地内置)openai-whisper(本地内置),这两种渠道不需要 .NET 依赖,兼容性更好。
  3. 重新安装 Whisper.NET 依赖(如果确实需要该渠道):
    在源码部署环境下,执行以下命令更新依赖包:

    uv sync --extra dotnet

    Windows 打包版用户如果出现此问题,通常是因为系统中不存在正确的 .NET 运行时,安装最新运行时即可。

补充说明

  • Whisper.NET 仅支持 Windows 平台,且需要 pythonnet>=3.0.1。错误中的 Method not found 是 .NET 运行时级别的兼容性问题,非软件 bug,请优先升级 .NET 运行时。

已安装安装 .NET 8.0
我的是AMD 7800xt显卡,系统是win11,该怎么处理

已安装 .NET 8.0 但仍报此错,说明 Whisper.NET 加载时仍使用了不兼容的运行时组件。请按以下步骤逐一排查和解决:

  1. 确认安装了正确的 .NET 运行时版本

    • 前往 .NET 8.0 运行时下载页,下载 .NET 8.0 (x64) 运行时(不是 SDK,注意选“Runtime”而非“SDK”)。
    • 安装后重启电脑,再运行软件测试。
  2. 检查系统环境变量

    • 在开始菜单搜索“环境变量”,打开“编辑系统环境变量” → “环境变量”。
    • 在“系统变量”中找到 Path,确认其中包含 C:\Program Files\dotnet\(默认安装路径)。若不存在,手动添加。
    • 打开命令提示符,输入 dotnet --info,确认输出中显示版本为 8.0.xxx
  3. 软件需使用打包版内置的 Whisper.NET

    • 如果你使用的是 Windows 打包版(sp.exe),请确保下载的是 2.6GB 完整版,而不是补丁包。
    • 检查 软件目录/models/ 下是否存在 ggml-large-v3.bin 模型文件(你日志中显示已存在)。
    • 若仍失败,可尝试删除 软件目录/models/ 下的所有 .bin 模型,重新启动软件,让软件自动重新下载模型。
  4. 临时替代方案(推荐)
    AMD 显卡目前只能通过 Whisper.NET(Vulkan)或 CPU 进行本地语音识别。若上述步骤无效,请改用 faster-whisper(CPU 模式)

    • 在主界面语音识别渠道选择 faster-whisper(本地内置),模型选 large-v3
    • 不要勾选 CUDA 加速(AMD 不能用 CUDA)。
    • 速度会慢一些,但功能正常。

    如果追求速度,建议使用在线语音识别 API,如:

    • OpenAI 语音识别 API
    • 字节语音大模型极速版
    • 阿里百炼 Qwen3-ASR
      这些无需本地 GPU,效果更好。
  5. 若仍坚持使用 Whisper.NET 并排查问题

    • 卸载已安装的 .NET 8.0,安装 .NET 9.0 运行时(更高版本通常兼容性更好)。
    • 从 GitHub 下载最新版 Whisper.NET NuGet 包,替换软件内的 _internal 目录下的相关 DLL。此操作较复杂,不建议普通用户尝试。

总结

  • 最直接稳定的方案:使用 faster-whisper(不勾选 CUDA)在线 API 渠道
  • 若必须用 Whisper.NET,请重装 .NET 8.0 运行时并重启。
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 via ko-fi.com

Dondate via PayPal

Related resource