#5921 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 "H:\pyvideotrans\videotrans\recognition\_whispernet.py", line 269, in _exec

processor.Process(audio_stream)

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 "H:\pyvideotrans\videotrans\task\only_one.py", line 47, in run

trk.recogn()

File "H:\pyvideotrans\videotrans\task\_stage_recogn.py", line 62, in recogn

raw_subtitles = run_recogn(

File "H:\pyvideotrans\videotrans\recognition\__init__.py", line 205, in run

return _cls(**kwargs).run()  # type:ignore

File "H:\pyvideotrans\videotrans\recognition\_base.py", line 92, in run

res = self._exec()

File "H:\pyvideotrans\videotrans\recognition\_whispernet.py", line 285, in _exec

raise SpeechToTextError(f"Whisper.net recognition failed: {str(e)}")

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:/_video_out/1-mp4,
临时文件夹: H:/pyvideotrans/tmp/52716/5c7d88d507
已选 清理已存在
未选 启用CUDA加速
未选 降噪
已选 识别说话人,最大说话人数量3
语音识别:Whisper.NET, model_name: ggml-large-v3.bin, 发音语言: 英语, 断句方式:默认断句
翻译渠道:微软(免费),原始语言:英语,目标语言:简体中文, 已选 发送完整字幕
未选 配音角色,不进行配音
字幕: 嵌入硬字幕
已选 分离人声与背景声, 已选 重新嵌入背景声, 背景音量0.8, 背景声音时长 短于 视频时长时: 拉长(降速播放),存在分离后的纯净人声文件,存在分离后的背景声音文件
代理地址:


=
system:Windows-10-10.0.26100-SP0
version:v4.06
frozen:False
language:zh
root_dir:H:/pyvideotrans
Python: 3.10.19 (main, Oct 28 2025, 12:01:56) [MSC v.1944 64 bit (AMD64)]

3 Replies

这是Whisper.net依赖的.NET运行时版本不兼容导致的错误。System.TimeSpan.FromMilliseconds(Int64) 方法是.NET 6.0新增的,你的系统上安装的.NET版本低于6.0(或缺少运行时)。

解决方案:

  1. 安装 .NET 6.0 或更高版本运行时
    前往 https://dotnet.microsoft.com/en-us/download/dotnet/6.0 下载并安装“ASP.NET Core Runtime 6.0.x”或“.NET Desktop Runtime 6.0.x”,重启软件。
  2. 如果仍失败,更换语音识别渠道
    在软件主界面“语音识别”下拉框中选择 faster-whisper(本地内置),该渠道不依赖.NET运行时,稳定性和兼容性更好。

注意:

  • 确认已执行过 uv sync --extra dotnet 安装pythonnet依赖。
  • Whispers.net 仅支持Windows平台,若在非Windows系统上会出现类似问题。

PS H:\pyvideotrans> uv run sp.py
error: Failed to generate package metadata for pynini==2.1.6.post1 @ direct+https://github.com/billwuhao/pynini-windows-wheels/releases/download/v2.1.6.post1/pynini-2.1.6.post1-cp310-cp310-win_amd64.whl
Caused by: Failed to fetch: https://github.com/billwuhao/pynini-windows-wheels/releases/download/v2.1.6.post1/pynini-2.1.6.post1-cp310-cp310-win_amd64.whl
Caused by: Request failed after 3 retries
Caused by: error sending request for url (https://github.com/billwuhao/pynini-windows-wheels/releases/download/v2.1.6.post1/pynini-2.1.6.post1-cp310-cp310-win_amd64.whl)
Caused by: operation timed out

该错误是因为无法从 github.com 下载 pynini 的预编译包,连接超时。这是由于网络环境无法正常访问 GitHub 导致的。

解决方案

  1. 确保能连接 github.com:如果在中国大陆,请开启科学上网工具(VPN/代理)并确保 GitHub 可访问。
  2. 重新执行安装命令:开启代理后,在终端中重新运行:

    uv sync
  3. 若仍失败:可尝试手动下载该 wheel 文件,然后使用 uv add 直接指向本地文件:

    • 下载链接:https://github.com/billwuhao/pynini-windows-wheels/releases/download/v2.1.6.post1/pynini-2.1.6.post1-cp310-cp310-win_amd64.whl
    • 将文件放入 H:\pyvideotrans 目录,然后执行:

      uv add pynini-2.1.6.post1-cp310-cp310-win_amd64.whl
      uv sync

注意:源码部署要求 Windows 系统必须能连接 github.com,否则安装会失败。如果无法解决网络问题,建议改用 Windows 预打包绿色版(.7z 完整包,约 2.7GB),解压后直接双击 sp.exe 即可使用,无需安装 Python 和依赖。

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