Whisper.net 主包不含任何运行时,必须另装 Whisper.net.Runtime 或对应加速运行时包才能跑;模型文件需自行准备并以 ggml-base.bin 这类路径传入 WhisperFactory.FromPath;Windows 需 VC++ 2022 运行库且要求 Windows 11/Server 2022 及以上,Linux 需 glibc 2.31。
whisper.net
sandrohaneaMIT活跃维护基于 Whisper 模型的 .NET 语音识别库,跨平台支持语音转文字与翻译,还内置 VAD 语音活动检测,方便在 C# 项目里直接接入。
Whisper.net. Speech to text made simple using Whisper Models
dotnet add package Whisper.net.AllRuntimes --version 1.9.1CPU 运行时全平台可用,但 x86/x64 需 CPU 支持 AVX、AVX2、FMA、F16C,否则改用 NoAvx 运行时;CUDA 运行时需支持 CUDA 的 NVidia GPU,并安装 CUDA Toolkit(CUDA 13 包需 >=13.0.1,Cuda12 包需 >=12.4.1);CoreML 面向 Apple 平台,OpenVino 需 OpenVino Toolkit >=2024.4,Vulkan 需 Vulkan Toolkit >=1.4.321.1。README 未给出显存要求。
基于 whisper.cpp 的 .NET 语音转文字绑定库,让 C# 项目几行代码接入 Whisper 模型
基于 Whisper 模型的 .NET 语音识别库,跨平台支持语音转文字与翻译,还内置 VAD 语音活动检测,方便在 C# 项目里直接接入。
核心能力
- 封装 whisper.cpp 提供 WhisperFactory 与 ProcessAsync 流式识别
- 按平台拆分运行时包,CPU、CUDA、CoreML、OpenVino、Vulkan 按需组合
- 支持 WithGrammar 用 GBNF 规则约束解码,适合固定语音指令
- 额外提供 Parakeet 模型家族及对应 CPU、CUDA、Vulkan 运行时包
- 覆盖 Windows、Linux、macOS、Android、iOS、WebAssembly 等平台
容易踩的坑
- preview-nativelibs-d1be6fdPreview NativeLibs 20261012-1604 (d1be6fd)pre-release2026-10-12 · 2026-10-12 16:05 UTC
查看更新说明
These are the native libraries built from whisper.cpp at commit
d1be6fd.This release was automatically generated on
20261012-1604. - preview-nativelibs-eacbd82Preview NativeLibs 20260906-0944 (eacbd82)pre-release2026-09-06 · 2026-09-06 09:45 UTC
查看更新说明
These are the native libraries built from whisper.cpp at commit
eacbd82.This release was automatically generated on
20260906-0944. - preview-nativelibs-371b5a7Preview NativeLibs 20260830-1316 (371b5a7)pre-release2026-08-30 · 2026-08-30 13:16 UTC
查看更新说明
These are the native libraries built from whisper.cpp at commit
371b5a7.This release was automatically generated on
20260830-1316. - preview-nativelibs-23ee035Preview NativeLibs 20260604-1012 (23ee035)pre-release2026-06-04 · 2026-06-04 10:12 UTC
查看更新说明
These are the native libraries built from whisper.cpp at commit
23ee035.This release was automatically generated on
20260604-1012. - 1.9.1v1.9.1最新正式版2026-06-01 · 2026-06-01 15:12 UTC
Highlights
- Added Voice Activity Detection (VAD) support, including
WhisperVadFactory,WhisperVadProcessor, builder/options APIs, VAD segment data, functional/unit tests, and a newexamples/Vadsample. - Added Silero VAD model support to
WhisperGgmlDownloader, including a dedicatedSileroVadTypeenum and downloader test coverage. - Added the
Whisper.net.Runtime.Cuda12runtime packages for Windows and Linux, with runtime-loader support and dependency-checker updates. - Improved language detection by exposing
whisper_lang_id()and adding candidate-basedDetectLanguageWithProbabilitysupport. - Bumped whisper.cpp through 1.8.5 and refreshed native build/test workflows.
- Simplified sampling strategy configuration by removing
IWhisperSamplingStrategyBuilder. - Improved
WhisperProcessorcancellation/instance handling and native failure/error-level propagation.
Compatibility & tooling
- Enabled XML documentation output for build/package artifacts.
- Included symbols in NuGet packages.
- Updated GitHub Actions and runner versions across managed, native, MAUI, NoAVX, CodeQL, package, and push workflows.
- Added repository Copilot instructions and reusable validation skills for managed API, native runtime, runtime-loading, package/release, MAUI, NoAVX, and test-model workflows.
- Updated Blazor reconnection handling and refreshed example package versions.
Dependency updates
- Updated Microsoft.Extensions.AI.Abstractions through 10.2.0.
- Updated Microsoft.Bcl.AsyncInterfaces through 10.0.7.
- Updated Microsoft.AspNetCore.Components.WebAssembly and Server through 10.0.5.
- Updated Microsoft.Extensions.Logging.Debug to 10.0.7.
- Updated NAudio to 2.3.0.
- Updated Microsoft.DotNet.XHarness.TestRunners.Xunit prerelease and coverlet.collector 10.0.0.
What's Changed
- Preparing dev branch for 1.9.1-preview1 to be merged after 1.9.0 release by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/455
- Fixed blazor example after dotnet 10 changes. by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/456
- Removed
IWhisperSamplingStrategyBuilderand refactored related sampling strategy builders by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/459 - Bump Microsoft.Extensions.AI.Abstractions from 10.0.0 to 10.0.1 by @dependabot[bot] in https://github.com/sandrohanea/whisper.net/pull/460
- use error levels from ggml library by @yuroller in https://github.com/sandrohanea/whisper.net/pull/463
- fix off by one error language prob array by @yuroller in https://github.com/sandrohanea/whisper.net/pull/465
- Bump Microsoft.Bcl.AsyncInterfaces from 10.0.0 to 10.0.1 by @dependabot[bot] in https://github.com/sandrohanea/whisper.net/pull/467
- Bump Microsoft.Extensions.AI.Abstractions from 10.0.1 to 10.1.1 by @dependabot[bot] in https://github.com/sandrohanea/whisper.net/pull/468
- expose whisper_lang_id() function by @yuroller in https://github.com/sandrohanea/whisper.net/pull/464
- Bump Microsoft.AspNetCore.Components.WebAssembly from 10.0.0 to 10.0.1 by @dependabot[bot] in https://github.com/sandrohanea/whisper.net/pull/469
- Bump Microsoft.AspNetCore.Components.WebAssembly.Server from 10.0.0 to 10.0.1 by @dependabot[bot] in https://github.com/sandrohanea/whisper.net/pull/470
- Added
whisper_lang_idtoINativeWhisperinterface in ProcessingFailureTests. by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/473 - Restore ios build by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/472
- Improved
DetectLanguageWithProbabilityto support candidate-based language detection by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/474 - Update iOS simulator version in GitHub workflows to 26.2 by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/476
- Adding Whisper.net.Runtime.Cuda12 by @sandrohanea in https://github.com/sandrohanea/whisper.net/pull/475
- Including symbols in
- Added Voice Activity Detection (VAD) support, including
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Whisper.net
Open-Source Whisper.net
Dotnet bindings for OpenAI Whisper made possible by whisper.cpp
Build Status
| Build type | Build Status |
|---|---|
| CI Status (Native + dotnet) |
Getting Started
To install Whisper.net with all the available runtimes, run the following command in the Package Manager Console:
PM> Install-Package Whisper.net.AllRuntimes
Or add a package reference in your .csproj file:
<PackageReference Include="Whisper.net.AllRuntimes" Version="1.9.1" />
Whisper.net is the main package that contains the core functionality but does not include any runtimes. Whisper.net.AllRuntimes includes all available Whisper and Parakeet runtimes, including CUDA 13 and CUDA 12 GPU builds.
Installing Specific Runtimes
To install a specific runtime, you can install them individually and combine them as needed. For example, to install the CPU runtime, add the following package references:
<PackageReference Include="Whisper.net" Version="1.9.1" />
<PackageReference Include="Whisper.net.Runtime" Version="1.9.1" />
GPT for Whisper
We also have a custom-built GPT inside ChatGPT, which can help you with information based on this code, previous issues, and releases. Available here.
Please try to ask it before publishing a new question here, as it can help you a lot faster.
Runtimes Description
Whisper.net comes with multiple runtimes to support different platforms and hardware acceleration. Below are the available runtimes:
Whisper.net.Runtime
The default runtime that uses the CPU for inference. It is available on all platforms and does not require any additional dependencies.
Examples:
- Simple usage example
- Simple usage example (without Async processing)
- NAudio integration for mp3
- NAudio integration for resampled wav
- Simple channel diarization
- Blazor example
Pre-requisites
- Windows: Microsoft Visual C++ Redistributable for at least Visual Studio 2022 (x64) Download Link
- Windows 11 or Windows Server 2022 (or newer) is required
- Linux:
libstdc++6,glibc 2.31 - macOS: TBD
- For x86/x64 platforms, the CPU must support AVX, AVX2, FMA and F16C instructions. If your CPU does not support these instructions, you'll need to use the
Whisper.net.Runtime.NoAvxruntime instead.
Supported Platforms
- Windows x86, x64, ARM64
- Linux x64, ARM64, ARM
- macOS x64, ARM64 (Apple Silicon)
- Android
- iOS
- MacCatalyst
- tvOS
- WebAssembly
Whisper.net.Runtime.NoAvx
For CPUs that do not support AVX instructions.
Pre-requisites
- Windows: Microsoft Visual C++ Redistributable for at least Visual Studio 2022 (x64) Download Link
- Windows 11 or Windows Server 2022 (or newer) is required
- Linux:
libstdc++6,glibc 2.31 - macOS: TBD
Supported Platforms
- Windows x86, x64, ARM64
- Linux x64, ARM64, ARM
Whisper.net.Runtime.Cuda
Contains the native whisper.cpp library with NVidia CUDA support enabled (built with the CUDA 13 toolchain).
Examples
Pre-requisites
- Everything from Whisper.net.Runtime pre-requisites
- NVidia GPU with CUDA support
- CUDA Toolkit (>= 13.0.1)
Supported Platforms
- Windows x64
- Linux x64
Whisper.net.Runtime.Cuda12
Contains the native whisper.cpp library with NVidia CUDA support enabled, built against the CUDA 12 toolchain for systems that only provide CUDA 12.x drivers.
Examples
Pre-requisites
- Everything from Whisper.net.Runtime pre-requisites
- NVidia GPU with CUDA support
- CUDA Toolkit (>= 12.4.1)
Supported Platforms
- Windows x64
- Linux x64
Whisper.net.Runtime.CoreML
Contains the native whisper.cpp library with Apple CoreML support enabled.
Examples:
Supported Platforms
- macOS x64, ARM64 (Apple Silicon)
- iOS
- MacCatalyst
Whisper.net.Runtime.OpenVino
Contains the native whisper.cpp library with Intel OpenVino support enabled.
Examples
Pre-requisites
- Everything from Whisper.net.Runtime pre-requisites
- OpenVino Toolkit (>= 2024.4)
Supported Platforms
- Windows x64
- Linux x64
Whisper.net.Runtime.Vulkan
Contains the native whisper.cpp library with Vulkan support enabled.
Examples
Pre-requisites
- Everything from Whisper.net.Runtime pre-requisites
- Vulkan Toolkit (>= 1.4.321.1)]
Supported Platforms
- Windows x64
Parakeet runtimes
Parakeet uses a separate native engine and standalone package family. Install Whisper.net.Runtime.Parakeet for CPU inference, or the matching accelerated package:
| Backend | Package |
|---|---|
| CPU | Whisper.net.Runtime.Parakeet |
| CPU without AVX | Whisper.net.Runtime.Parakeet.NoAvx |
| CUDA 13 | Whisper.net.Runtime.Parakeet.Cuda |
| CUDA 12 | Whisper.net.Runtime.Parakeet.Cuda12 |
| Vulkan | Whisper.net.Runtime.Parakeet.Vulkan |
Parakeet supports the same Windows, Linux, macOS, Android, Apple mobile, and WebAssembly platforms as the corresponding Whisper backend. CoreML and OpenVINO are Whisper-only.
Use the normal factory, builder, and processor workflow, but select the model family explicitly:
using var factory = WhisperFactory.FromPath(modelPath, new()
{
ModelFamily = WhisperModelFamily.Parakeet,
});
using var processor = factory.CreateBuilder().Build();
Whisper remains the default because Whisper and Parakeet model files cannot be reliably distinguished from their file header. Translation, language selection/detection, prompts, beam search, temperature fallback, token timestamps, native print options, Flash Attention, DTW, CoreML, and OpenVINO are not supported by the Parakeet engine; explicitly configuring them throws NotSupportedException. Voice activity detection (WhisperVadFactory) is a Whisper-only feature that always loads the Whisper native engine regardless of WhisperFactoryOptions.ModelFamily, so it cannot be paired with the Parakeet engine.
Parakeet results use the shared SegmentData and WhisperToken types. SegmentData.Language is empty and NoSpeechProbability is float.NaN; Whisper-only token fields are zero.
See the Parakeet example for a complete transcription flow.
Multiple Runtimes Support
You can install and use multiple runtimes in the same project. The runtime will be automatically selected based on the platform you are running the application on and the availability of the native runtime.
The following order of priority will be used by default:
Whisper.net.Runtime.Cuda(NVidia devices with CUDA 13 drivers installed)Whisper.net.Runtime.Cuda12(NVidia devices with CUDA 12 drivers installed)Whisper.net.Runtime.Vulkan(Windows x64 with Vulkan installed)Whisper.net.Runtime.CoreML(Apple devices)Whisper.net.Runtime.OpenVino(Intel devices)Whisper.net.Runtime(CPU inference)Whisper.net.Runtime.NoAvx(CPU inference without AVX support)
The loader automatically probes the CUDA runtimes in this order and validates the installed driver via cudaRuntimeGetVersion, so machines with only CUDA 12 drivers will transparently fall back to Whisper.net.Runtime.Cuda12.
To change the preferred runtime order, set RuntimeLibraryOrder on RuntimeOptions:
RuntimeOptions.RuntimeLibraryOrder =
[
RuntimeLibrary.CoreML,
RuntimeLibrary.OpenVino,
RuntimeLibrary.Cuda,
RuntimeLibrary.Cuda12,
RuntimeLibrary.Cpu
];
Setting RuntimeLibraryOrder changes the preferred order, but compatibility checks are still performed before a runtime is loaded. If your application performs its own hardware and software detection, you can force a runtime and bypass those checks:
RuntimeOptions.ForcedRuntimeLibrary = RuntimeLibrary.Cpu;
Parakeet runtime selection is independent, so both engines can use different backends in the same process:
RuntimeOptions.ParakeetRuntimeLibraryOrder =
[
RuntimeLibrary.Vulkan,
RuntimeLibrary.Cpu
];
RuntimeOptions.ForcedParakeetRuntimeLibrary = RuntimeLibrary.Cpu;
Set ForcedRuntimeLibrary before creating any WhisperFactory. Only the specified runtime will be considered; native library path resolution and loading will still occur normally, but automatic checks such as CPU instruction-set and CUDA availability detection will be skipped. The application is responsible for ensuring the selected runtime is compatible. Forcing an incompatible runtime can cause native library loading failures or process crashes due to unsupported CPU instructions.
This override can also be used by Native AOT applications that perform their own runtime hardware detection, without raising the managed application's instruction-set baseline.
Pluggable native runtimes
- Whisper.net can run with any compatible compilation of the native whisper.cpp libraries; the package Whisper.net.Runtime is just one of the possible builds we publish.
- You may build your own native binaries (CPU, CUDA, CoreML, OpenVINO, Vulkan, NoAvx) and use them with Whisper.net as long as their files are arranged under ./runtimes in the same layout as our NuGet packages. The NativeLibraryLoader will probe them at runtime.
- For reproducible builds, you can use the attached GitHub workflows as references or entry points to produce artifacts: .github/workflows/ (e.g., dotnet.yml, dotnet-noavx.yml, dotnet-maui.yml). These workflows compile and package native libraries across platforms and can be adapted for your needs.
Versioning
Whisper.net follows semantic versioning.
Starting from version 1.8.0, Whisper.net does not follow the same versioning scheme as whisper.cpp, which creates releases based on specific commits in their master branch (e.g., b2254, b2255).
To track the whisper.cpp version used in a specific Whisper.net release, you can check the whisper.cpp submodule. The commit hash for the tag associated with the release will indicate the corresponding whisper.cpp version.
Ggml Models
Whisper.net uses Ggml models to perform speech recognition and translation. You can find more about Ggml models here.
For easier integration, Whisper.net provides a Downloader using Hugging Face.
var modelName = "ggml-base.bin";
if (!File.Exists(modelName))
{
using var modelStream = await WhisperGgmlDownloader.Default.GetGgmlModelAsync(GgmlType.Base);
using var fileWriter = File.OpenWrite(modelName);
await modelStream.CopyToAsync(fileWriter);
}
The same downloader can fetch the ggml Silero VAD model used by WhisperVadFactory:
var vadModelName = "ggml-silero-v6.2.0.bin";
if (!File.Exists(vadModelName))
{
using var modelStream = await WhisperGgmlDownloader.Default.GetGgmlSileroVadModelAsync();
using var fileWriter = File.OpenWrite(vadModelName);
await modelStream.CopyToAsync(fileWriter);
}
using var vadFactory = WhisperVadFactory.FromPath(vadModelName);
Parakeet TDT 0.6B v3 models are mirrored in sandrohanea/whisper.net at v5 in F32, F16, Q8_0, Q4_0, and Q4_K variants. All Whisper, Parakeet, encoder, and VAD downloads use this shared fixed version rather than an upstream main branch. Existing Whisper, encoder, and VAD model bytes are unchanged from v4, which remains available for older Whisper.net releases.
The mirrors preserve the converted files from ggml-org/parakeet-GGUF at 35156454d1a39de06863303dd209fd2bed6ee079. NVIDIA's original Parakeet TDT 0.6B v3 weights are licensed under CC-BY-4.0; the conversion repository declares MIT, which does not replace the original weights' attribution obligations. The mirror's provenance and checksum manifest records both sources. For example, the Q4_0 model is approximately 356 MB:
using var modelStream = await WhisperGgmlDownloader.Default.GetGgmlParakeetModelAsync(
ParakeetModelType.Tdt0_6B_V3,
ParakeetQuantizationType.Q4_0);
using var fileWriter = File.Create("ggml-parakeet-tdt-0.6b-v3-q4_0.bin");
await modelStream.CopyToAsync(fileWriter);
Models can also be supplied from managed sources without writing native code. Use FromStream, FromBuffer, or implement IWhisperModelLoader when the model comes from a custom source:
using var whisperModelStream = await GetWhisperModelStreamAsync();
using var whisperFactory = WhisperFactory.FromStream(whisperModelStream);
using var vadModelStream = await GetVadModelStreamAsync();
using var vadFactory = WhisperVadFactory.FromStream(vadModelStream);
The Silero VAD model can also be built from the whisper.cpp submodule:
python -m venv venv
.\venv\Scripts\Activate.ps1
pip install silero-vad
python .\whisper.cpp\models\convert-silero-vad-to-ggml.py --output .\whisper.cpp\models\silero.bin
The conversion script names the output with the Silero package version, for example silero-v6.2.0-ggml.bin. The current v5 snapshot includes this model as vad/ggml-silero-v6.2.0.bin. Future model updates require a new Hugging Face version tag and an update to the downloader's shared model version; do not move existing tags.
Environment variables for model downloads
- HF_TOKEN
- Optional. If set, Whisper.net will add an Authorization header when downloading models from Hugging Face to avoid rate limiting.
- Example:
- Bash:
export HF_TOKEN=hf_xxx - PowerShell:
$env:HF_TOKEN = "hf_xxx"
- Bash:
Usage
using var whisperFactory = WhisperFactory.FromPath("ggml-base.bin");
using var processor = whisperFactory.CreateBuilder()
.WithLanguage("auto")
.Build();
using var fileStream = File.OpenRead(wavFileName);
await foreach (var result in processor.ProcessAsync(fileStream))
{
Console.WriteLine($"{result.Start}->{result.End}: {result.Text}");
}
Grammar constraints
Use WithGrammar to guide Whisper decoding with GBNF rules, for example when recognizing a fixed set of voice commands:
using var processor = whisperFactory.CreateBuilder()
.WithLanguage("ro")
.WithGrammar("""
root ::= " "* ("pornește" | "oprește" | "continuă") [ .!?]*
""")
.Build();
WithGrammar(gbnf, startRule: "root", penalty: 100f) accepts literals, Unicode character classes and ranges (including negated classes), rule references, groups, alternatives, and *, +, ? repetition. Rules are separated by newlines; # starts a comment. Invalid syntax, undefined rules, and left recursion are rejected before processing. The processor owns and releases native grammar memory.
Whisper subtracts the penalty from logits of incompatible tokens; this does not guarantee that every result is complete or valid. Restricting characters also does not guarantee a language when languages share an alphabet. Use a multilingual model and WithLanguage for foreign-language transcription; WithTranslate() requests English translation. Grammar constraints are unavailable for Parakeet.
Documentation
You can find the documentation and code samples here.
- Development environment setup notes are available in DEVELOPMENT.md.
Running tests
For instructions on running the test suites locally (including required .NET SDKs, optional environment variables like HF_TOKEN), see tests/README.md.
- Offline/local alternative: You can run tests fully locally without network by pre-downloading all ggml models required by tests and pointing tests to them via WHISPER_TEST_MODEL_PATH.
- MAUI tests use the Dotnet XHarness CLI to drive emulators/simulators. Docs: https://github.com/dotnet/xharness
- Native runtimes: By default, tests and are using the locally built native binaries instead, see “Building The Runtime” in DEVELOPMENT.md and ensure the output matches the expected runtimes layout.
License
MIT License. See LICENSE for details.