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

240e:39c* Posted at: 7 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/30772/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

5 Replies

这个错误是由于 Whisper.net 依赖的 .NET 运行时方法缺失导致的,通常是因为系统中缺少所需的 .NET 运行库或版本过低。

解决方案:

  1. 安装 .NET 6.0 桌面运行时
    访问微软官方下载页面:https://dotnet.microsoft.com/en-us/download/dotnet/6.0
    下载并安装 .NET Desktop Runtime 6.0.x (x64) 版本,安装后重启软件重试。
  2. 切换语音识别渠道
    如果不想安装 .NET 运行时,请将语音识别渠道改为 faster-whisper(本地内置),选择模型 large-v3,质量与速度均可。这样无需额外依赖 .NET。
  3. 确认依赖已安装
    如果你是通过源码部署,请确保已执行 uv sync --extra dotnet 安装了 Whisper.net 的 Python 绑定。

请尝试以上步骤,通常安装 .NET 6.0 桌面运行时即可解决。如果问题依旧,请检查 logs/ 目录下的最新日志文件,提供更多上下文以便进一步分析。

安装的就是 .NET Desktop Runtime 6.0.x (x64) 版本

System.TimeSpan.FromMilliseconds(Int64) 方法在 .NET 6.0 中存在,但在 .NET 5 及以下版本中可能缺失,因此这个错误很可能是因为你的系统中实际加载的 .NET 运行时版本不是 6.0(例如安装了 .NET 6.0 SDK 但缺少 Desktop Runtime,或者运行时路径被旧版 .NET 覆盖)。请按以下顺序排查:

  1. 确认已安装 .NET Desktop Runtime 6.0(含桌面运行时)
    打开命令提示符,执行:

    dotnet --list-runtimes

    查看输出中是否包含 Microsoft.WindowsDesktop.App 6.0.x。如果没有,说明你只安装了 SDK 或控制台运行时,缺少桌面运行时(WindowsDesktop)。请从 微软官方 .NET 6.0 下载页面 下载并安装 .NET Desktop Runtime 6.0 (x64)(注意不是 SDK,不是 ASP.NET Core Runtime)。

  2. 尝试安装 .NET 8.0 Desktop Runtime
    Whisper.net 的新版本可能要求 .NET 8.0 或更高。直接安装 .NET 8.0 Desktop Runtime (x64),重启软件。
  3. 如果仍无法解决,请更换语音识别渠道
    在软件主界面右侧的语音识别下拉框中,选择 faster-whisper(本地内置),模型选 large-v3。此渠道不依赖 .NET,质量与速度均优,是推荐方案。

如果问题依旧,请提供 dotnet --list-runtimes 的输出截图,以及软件 logs/ 目录下的最新日志,以便进一步定位。

PS C:\Users\Administrator> dotnet --list-runtimes
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

你的 .NET Desktop Runtime 6.0.36 和 8.0.29 均已安装正确,问题不在运行时缺失。System.TimeSpan.FromMilliseconds(Int64) 方法在 .NET 6.0+ 中存在,但错误提示"Method not found"说明 Whisper.net 实际加载的运行时版本可能被干扰(如系统环境变量 PATH 中混入了旧版 .NET 路径,或 Whisper.net 引用了不兼容的 API)。请按以下顺序处理:彻底重启系统 安装运行时后未重启可能导致新运行时未生效。重启电脑后再试。重新安装 Whisper.net 依赖(源码部署) 打开终端进入软件目录,执行:bashuv sync --extra dotnet重新生成 .NET 绑定。更新 pythonnet 和 Whisper.net 到最新版 在源码目录执行:bashuv add pythonnet whisper.net然后重新运行软件。切换为推荐渠道 如果你使用的是 Windows 预打包版,或不想再排查此问题,请将语音识别渠道切换为 faster-whisper(本地内置),模型选 large-v3。这是最成熟、质量最好的渠道,不依赖 .NET。如果以上操作均无法解决,请提供以下信息以便进一步分析:- 软件版本号(左上角显示)- 软件安装目录下 logs/ 中最新的 .log 文件内容(复制最后 50 行)

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