TranscribeCppSharp
.NET bindings for transcribe.cpp: load GGUF speech-to-text models and transcribe audio (16 kHz mono float PCM) from C#.
Four ways to use it:
- A command-line tool —
dotnet tool install -g TranscribeCppSharp.Cli gives you transcribe, which downloads a curated model on first use and prints or exports the transcript. See Command-line tool.
- A .NET library — the
TranscribeCppSharp wrapper (plus the native runtime package for your platform) for C# code. See Getting started.
- A desktop app —
TranscribeCppSharp.UI, an Avalonia GUI over the same wrapper. Each release attaches a self-contained archive per platform (not a NuGet package); you can also run it from a clone. See Desktop app.
- An OpenAI-compatible server —
TranscribeCppSharp.Server serves one loaded model over HTTP (/v1/audio/transcriptions, /v1/audio/translations) with the routes OpenAI's audio API uses. Run it from a clone; there is no package or archive for it yet. See OpenAI-compatible server.
📖 Full documentation → — the guide, the reference, and the measured limits with the method behind each one. Published from docs/; this README is the short version and the details are delegated to those pages.
Installation
The wrapper is platform-agnostic and ships no native binaries. A minimal install is the wrapper plus the native runtime package for your platform:
dotnet add package TranscribeCppSharp
dotnet add package TranscribeCppSharp.Native.linux-x64 # pick your platform
If you would rather not pick a platform (or want one package that works everywhere), install the bundle meta-package instead — it pulls the wrapper and every native runtime:
dotnet add package TranscribeCppSharp.Bundle
Native runtime packages: TranscribeCppSharp.Native.linux-x64,
.linux-arm64, .win-x64, .osx-arm64, .osx-x64.
The wrapper and TranscribeCppSharp.Interop ship lib/net8.0, lib/net9.0 and
lib/net10.0 assemblies, and TranscribeCppSharp.Bundle mirrors that list as one
dependency group per target. The lower two exist so a project still on those
runtimes can reference the package at all; they are compatibility assets, not a
support promise — .NET 9 has been out of support since May 2026, .NET 8 reaches
end of support in November 2026, and .NET 10 is the current LTS. CI runs the
smoke test on all three, so the net8.0/net9.0 assemblies are at least known to
load the native library and transcribe; the test suite itself runs on net10.0.
Note: For Linux Alpine (musl) or other platforms, see
Building from source. Like
Using CUDA, a custom native build is picked up
automatically when placed in the app output directory.
The wrapper resolves libtranscribe automatically in plain dotnet run scenarios (no
<RuntimeIdentifier> needed), and accepts only the transcribe.cpp version the bindings
were generated for. If no compatible native library is found (e.g. you forgot the runtime
package, or only an older version is left in the NuGet cache), the wrapper throws a
DllNotFoundException that lists the exact package and version to add, the paths it
searched, and any candidate it rejected for its version. It does not silently load a
stale library or produce a misleading error. See
Installation and
Native library loading.
Quick Start
The four snippets below are checked by a test: each is compared byte-for-byte against a
marked region in HighLevelApiTests.cs and samples/SmokeTest/Program.cs, so they
cannot drift from the API without failing the build
(ReadmeExamplesTest).
Basic Transcription
Model.Load initializes the compute backends automatically on first use, but you can (and for custom setups, should) do it explicitly with Backends.InitDefault():
Backends.InitDefault(); // optional: automatic in Model.Load, but explicit is clearer
var modelPath = TestConfig.ModelPath; // your GGUF model file, e.g. "test-models/ggml-tiny.bin"
var audioPath = TestConfig.AudioPath; // your WAV audio file, e.g. "test-audio/jfk.wav"
using var model = Model.Load(modelPath, p => p.WithBackend(BackendRequest.BackendCpu));
using var session = model.CreateSession();
var pcm = PcmExtensions.ReadWavToPcm(audioPath);
var transcript = session.Run(pcm);
Omit the WithBackend call to get the default AUTO policy, which runs on the GPU
whenever one initializes — see Compute.
Batch Processing
Backends.InitDefault(); // optional: automatic in Model.Load, but explicit is clearer
var modelPath = TestConfig.ModelPath; // your GGUF model file, e.g. "test-models/ggml-tiny.bin"
var audioPath = TestConfig.AudioPath; // your WAV audio file, e.g. "test-audio/jfk.wav"
using var model = Model.Load(modelPath, p => p.WithBackend(BackendRequest.BackendCpu));
using var session = model.CreateSession();
var pcm1 = PcmExtensions.ReadWavToPcm(audioPath);
var pcm2 = PcmExtensions.ReadWavToPcm(audioPath);
var results = Batch.Run(session, new[] { pcm1, pcm2 });
Real-Time Streaming
stream.Begin();
int chunkSize = 16000; // 1 second
for (int i = 0; i < pcm.Length; i += chunkSize)
{
int length = Math.Min(chunkSize, pcm.Length - i);
var chunk = pcm.AsSpan(i, length);
stream.Feed(chunk);
}
stream.Complete();
var text = stream.GetCurrentText();
Model Capabilities
A model is asked what it can do, not assumed. model.Supports(Feature.FeatureDiarization)
is the one worth calling before a run:
Backends.InitDefault(); // optional: automatic in Model.Load, but explicit is clearer
var modelPath = TestConfig.ModelPath; // your GGUF model file, e.g. "test-models/ggml-tiny.bin"
using var model = Model.Load(modelPath, p => p.WithBackend(BackendRequest.BackendCpu));
var supportsPnc = model.Supports(Feature.FeaturePnc);
var caps = model.GetCapabilities();
Speaker attribution, long audio and windowing: Long audio and diarization.
Desktop app
TranscribeCppSharp.UI is an Avalonia app on .NET 10 that drives
the same wrapper and the same native library — it adds no transcription logic of its own, and
its limits are the library's. It is built in CI on Linux, macOS and Windows.
Each release attaches a
self-contained archive per platform — TranscribeCppSharp.UI-<version>-<rid>.zip for
win-x64, linux-x64, linux-arm64, osx-arm64 and osx-x64. Unzip it and run the
executable: it carries the .NET runtime and the matching native transcribe.cpp build, so no
SDK is needed. Each archive also carries the project LICENSE and the upstream component
licences under licenses/. The caveats, stated plainly:
- The archives are not code-signed, so Windows SmartScreen and macOS Gatekeeper will warn
or refuse on first launch. There is no installer and no notarization.
- macOS ships a bare executable, not a
.app bundle (no Info.plist), so it has no Dock
name or Finder integration, and Gatekeeper treats it like any unsigned download — clear the
quarantine if it refuses to run: xattr -dr com.apple.quarantine TranscribeCppSharp.UI.
- They carry no
ffmpeg, which the app still needs on PATH for any non-WAV input and
for the microphone (Audio input).
To build from source instead, fetch the native libraries once and then start it:
dotnet run --project tools/FetchNative # once: the native library the app loads
dotnet run --project src/TranscribeCppSharp.UI
Six tabs, one per job:
| Tab |
What it does |
| Transcription |
Pick a file, a model and the decoder settings (language, threads, KV type, context size, window length, and the knobs that only some model families have). The result comes back as text, as segments, as words, or as speaker-attributed segments, and exports to .txt, .vtt, .html, .md, .json, .srt or .ass. |
| Streaming |
Transcribe the microphone live, with committed text on the left and the tentative part the model may still revise on the right. The commit policy and the family-specific knobs are there. |
| Batch |
Queue several files and run them one after another against one loaded model, then export the results as .txt or .json. |
| History |
The transcriptions finished on this machine, saved locally, newest first, with open and delete. Opening one loads it into the Transcription tab without transcribing again. |
| Models |
The 76 curated aliases, filterable by alias, family, size, licence, language, or what is already on disk, with per-row download, measure and delete. It can also time a model on audio you choose, on your machine, for this session only. |
| Settings |
Backend and device selection, the cache directory, the native library's version, and the compute devices this build can see. |
Three things worth knowing before you rely on it:
- It shares the model cache with the
transcribe CLI. A model downloaded in one is
there for the other, and the Models tab can delete what the CLI fetched. The three tabs
that run a model list only what is on disk, so a model fetched by the CLI appears in
them without you having to fetch it again; under each picker a count and a Get more…
button say how to get the rest.
- It asks the model what it can do, instead of guessing from the name. Loading is the
only way the native library answers — the manifest declares no capabilities — so a model
that is not on disk keeps every option visible and the app says so underneath the picker.
Options are hidden only once a loaded model has said it lacks the feature.
- It quotes upstream's accuracy figures instead of inventing its own. The
WER column
and the model detail pane carry transcribe.cpp's own headline error rate, with the metric,
dataset, split and language in the tooltip — useful for narrowing the field, but not one
sortable ranking, because the figures mix WER, CER and DER across datasets. The app links
transcribe.cpp's per-model tables and each model's Hugging Face card, where the full WER
and language matrices live. Measure times a model on your audio and reports speed only, and
Streaming benchmarks is the one benchmark this project runs
(Moonshine streaming).
The tab that carries the library's limits is Streaming: the app calls the same
StreamSession the CLI and the library do, so the native abort documented in
Streaming benchmarks applies here too and is not a GUI bug.