Recursive AI

.NET speech to text: batch or live?

For .NET speech to text, use batch for a single transcript of a finished recording or live recognition to get text while audio is still arriving.

OneSpeech is a free, open-source .NET library from Recursive AI, licensed under MIT or Apache-2.0. NuGet · GitHub

Install for .NET 10: dotnet add package RecursiveAI.OneSpeech --version 1.1.0

On first use, OneSpeech downloads uncached model weights: Whisper base is 290.4 MB here, while leaving model unset in the batch call fetches the default Whisper large-v3-turbo (1,617.8 MB), before any companion models.

Batch: transcribe a finished recording

In a .NET 10 console project, save jfk.wav in the project directory. It’s an 11-second public-domain excerpt from John F. Kennedy’s inaugural address. The speech-to-text cookbook documents the recording’s provenance.

Program.cs.NET 10
using OneSpeech;
 
var transcript = Speech.Transcribe("jfk.wav",
    language: "en", model: "openai/whisper-base");
Console.WriteLine($"Batch: {transcript.Text}");
OutputTerminal
Batch: And so my fellow Americans, ask not what your country can do for you, ask what you can do for your country.

Live: replay the same recording as PCM

From the same project directory, run this FFmpeg command to create speech.f32 from jfk.wav. The command is silent on success.

Prepare the PCM replay fileShell
ffmpeg -hide_banner -loglevel error -y -i jfk.wav -ac 1 -ar 16000 -f f32le speech.f32

Replace Program.cs with the live example. It reads 20 ms blocks from the PCM file without a microphone or real-time pacing.

Program.cs.NET 10
using OneSpeech;
 
await foreach (var update in Speech.Listen(ReadPcm("speech.f32"),
    language: "en", model: "openai/whisper-base"))
{
    if (update is FinalEvent final)
        Console.WriteLine($"Live final: {final.Segment.Text}");
}
 
static async IAsyncEnumerable<AudioBuffer> ReadPcm(string path)
{
    await using var file = File.OpenRead(path);
    var bytes = new byte[320 * sizeof(float)];
    int count;
    while ((count = await file.ReadAtLeastAsync(bytes, bytes.Length, false)) > 0)
    {
        var samples = new float[count / sizeof(float)];
        for (int i = 0; i < samples.Length; i++)
            samples[i] = System.Buffers.Binary.BinaryPrimitives
                .ReadSingleLittleEndian(bytes.AsSpan(i * sizeof(float)));
        yield return new AudioBuffer(samples, sampleRate: 16000);
    }
}
OutputTerminal
Live final: And so my fellow Americans.
Live final: ASK NOT!
Live final: what your country can do for you.
Live final: Ask what you can do for your country.

“ASK NOT!” is the model’s raw output. The replay prints four final segments, with their original capitalization and punctuation.

Choose by the result your app needs

Batch recognition

Use caseArchive a completed interview or meeting
APISpeech.Transcribe
ResultOne Transcript with segments, word timing where available, and document-local speaker labels. The default diarizer doesn’t detect overlapping speech. Batch behavior

File streaming

Use caseIndex a long recording incrementally
APISpeech.TranscribeStream
ResultFinal segments from a file or encoded stream without retaining all decoded PCM. No whole-file speaker assignment. File-streaming behavior

Live recognition

Use caseDisplay captions during speech
APISpeech.Listen
ResultEvents from caller-supplied mono 16 kHz PCM. With streaming Moonshine, replace the draft for the current utterance on each partial and append the final once. Live event contract

Listen doesn’t capture a microphone. In production, supply blocks from your capture or network layer, mix and resample there if needed, and pass cancellation from the lifetime of the session. The example prints only finals. A caption UI should also handle partials as replacements, not extra lines; the AudioTime on an event describes accepted audio, not end-to-end wall-clock latency.

Choose a model before packaging the app

The example explicitly uses Whisper base for both calls. If you omit the model, OneSpeech 1.1.0 defaults to Whisper large-v3-turbo for batch and Moonshine streaming tiny for live. That Moonshine checkpoint is for English recognition and can emit partials. With an offline-family model like Whisper base, the live utterance session emits finals only. If users need text before they pause, test a checkpoint that emits partials in their language rather than assuming that streaming input implies streaming text. See Moonshine’s language and streaming behavior and the model catalog.

Measure on the machine that will run recognition. For batch, check transcription errors, timing and speaker labels on representative files. For live, replay real capture at its original pace and check time to first useful draft, draft revisions, and time from a pause to the final caption. Test on your actual accents, background noise, and hardware before picking a model.

Budget for the model cache, not just the NuGet package

Inference runs locally, but the first call can fetch weights. The v1.1.0 model download table lists 1,617.8 MB of publisher weights for Whisper large-v3-turbo and 176.2 MB for Moonshine streaming tiny. Those aren’t install totals: the cache can also hold converted weights, a CAM++ speaker embedder, and timing models. The recognizer’s size alone doesn’t tell you what a batch call needs.

For a disconnected deployment, prepare the exact model and language with Speech.PrefetchAsync, provision the resulting cache for the runtime user, and test a real call with the network disabled. The offline NuGet model packages carry certain pinned models, not every companion role. Keep the published onespeech-models directory beside the executable when using those packages. Check each checkpoint’s notices separately from the library license.

Deployment references: OneSpeech documentation and when to replace System.Speech grammar recognition.