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

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

该错误是由于系统缺少或版本不兼容的 .NET 运行时,导致 Whisper.NET 引擎无法找到 System.TimeSpan.FromMilliseconds(Int64) 方法。Whisper.NET 依赖 .NET 运行时来加载 ggml 模型。

解决方案

  1. 安装 .NET Desktop Runtime 6.0 或更高版本
    前往微软官网下载并安装 .NET 6.0 Desktop Runtime (x64)(或更新版本如 .NET 8.0)。安装后重启软件。
  2. 更换为其他语音识别渠道(推荐)
    Whisper.NET 并非必须,且仅支持 Windows。建议在主界面语音识别渠道中选择 faster-whisper(本地内置) 并选择 large-v3 模型,效果相当且无需 .NET 依赖。
  3. 若仍使用 Whisper.NET
    确保系统环境变量 PATH 包含 .NET 运行时路径,或使用 --extra dotnet 重新安装依赖(源码部署用户适用,打包版无需此操作)。

确保系统环境变量 PATH 包含 .NET 运行时路径,如何实现

在 Windows 上安装 .NET Desktop Runtime 后,安装程序通常会自动将运行时路径添加到系统环境变量 PATH 中。如果未生效,可手动检查并添加。

  1. 确认安装路径
    默认 .NET 6.0 Runtime 安装路径为:
    C:\Program Files\dotnet
    (若安装其他版本,路径类似)
  2. 打开环境变量编辑器

    • Win + R,输入 sysdm.cpl,回车。
    • 切换到「高级」选项卡,点击「环境变量」。
    • 在「系统变量」列表中找到 Path,选中后点击「编辑」。
  3. 添加 .NET 路径
    点击「新建」,输入以下两项(若已有则跳过):

    • C:\Program Files\dotnet
    • C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.xx(其中 6.0.xx 替换为你的具体版本号,如 6.0.35
  4. 保存并重启
    依次点击「确定」保存所有窗口,然后重启 pyVideoTrans 软件。
  5. 验证
    打开命令提示符(CMD),输入 dotnet --info,正常显示版本信息即表示配置成功。

如果仍然报错,建议直接换用 faster-whisper 渠道,无需 .NET 依赖。

变量名:C:\Program Files\dotnet
变量值:C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.xx

您提供的写法是错误的。环境变量配置中,变量名应填写 Path(系统已有的变量),变量值应追加路径,而不是新建一个变量名为路径的变量。请按以下步骤修正:1. 打开「系统属性」→「高级」→「环境变量」。2. 在「系统变量」列表中,找到变量名为 Path 的项,选中后点击「编辑」。3. 点击「新建」,分别添加以下两行路径(一行一个): - C:\Program Files\dotnet - C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.xx (请将 6.0.xx 替换为实际安装的版本,如 6.0.35)4. 点击「确定」保存所有窗口。5. 重启 pyVideoTrans 再试。若仍报错,建议直接改用 faster-whisper(本地内置) 渠道,无需 .NET 依赖,效果稳定。

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