Download speech-to-text models before disconnecting; prefetch prepares the recognizer and its timing and speaker models.
dotnet add package RecursiveAI.OneSpeechRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneSpeech; await Speech.PrefetchAsync(language: "en", model: "openai/whisper-tiny"); Console.WriteLine("Speech-to-text models ready.");
Speaker embeddings are biometric data. Obtain informed consent, limit retention and access, and check applicable law, including Illinois BIPA and GDPR Article 9, before enrollment, identification or verification. The library does not persist embeddings; applications remain responsible for audio, transcripts, logs and any copies they retain. This is not legal advice.
Unzip the example, then dotnet run.
Prints:
Speech-to-text models ready.Then transcribe with no network: Load a prepared speech model offline in C#. Use the same recognizer, language and cache when preparing and transcribing.
Without an override, the cache is LocalApplicationData/OneSpeech/models on Windows, ~/Library/Caches/OneSpeech/models on macOS, and $XDG_CACHE_HOME/onespeech/models (or ~/.cache/onespeech/models) on other platforms. Change the model cache directory before preparation if you need another location.
The full program
using OneSpeech; using var cancellation = new CancellationTokenSource(); Console.CancelKeyPress += (_, e) => { e.Cancel = true; cancellation.Cancel(); }; await Speech.PrefetchAsync(language: "en", model: "openai/whisper-tiny", cancellationToken: cancellation.Token); Console.WriteLine("Speech-to-text models ready.");
Speech.PrefetchAsync uses ModelStore.Default, the process-wide store also used by later Speech calls. This program keeps that store so preparation and transcription use the same cache; it does not pull the model a second time. The selected models need no account or key. On an empty cache, the call downloads publisher files and converts them into the files OneSpeech loads for inference; the zip does not include model weights. Download or integrity errors fail the call instead of reporting readiness. Ctrl+C requests cancellation.
Speech-to-text models ready.Variations
To prepare the live default instead, replace the PrefetchAsync call with this line:
await Speech.PrefetchAsync(language: "en", model: "moonshine-ai/moonshine-streaming-tiny");The call itself prints nothing. With the full program’s success message, it prints Speech-to-text models ready.
Prepare only the English speaker model, without a recognizer or word-timing models:
using OneSpeech; await Speech.PrefetchAsync(language: "en", model: "iic/speech_campplus_sv_en_voxceleb_16k"); Console.WriteLine("Speaker model ready.");
Speaker model ready.Related recipes
The short answer
Call Speech.PrefetchAsync while the machine has network access, with an explicit model ID and language hint. The method prepares model files but does not load inference sessions. Keep the same cache available to the account that will run your offline application.
The example selects the Whisper tiny speech recognizer for English. Prefetch also prepares the models that OneSpeech can use to time words and group speech by speaker. Downloading only the recognizer’s weights is not enough to prepare every part of a later transcription call.
How do I download speech models for offline use in C#?
Choose the operation first. File transcription and live listening have different defaults and need different additional models. Pass the recognizer ID you actually plan to use rather than relying on a default that your application does not otherwise specify. For example, the documented file recognizer ID openai/whisper-tiny can be passed as the model argument with language: "en".
For a recognizer, prefetch prepares files for both file transcription and live listening. Depending on the recognizer and language, this includes Qwen to find word times, a CTC model as a timing fallback, and a speaker model to group speech by voice. Without a language hint it includes both English and Chinese speaker models and Qwen timing for eventual language detection. Some of these files might not be used by one particular recording.
The main example prepares the file recognizer. Use the live variation when preparing the default recognizer for Listen. If you use the separate Align operation to find the times of supplied text, prepare each timing model that operation can use. The first-use model documentation lists which models each operation needs.
Can I use downloaded speech models offline?
Yes, when the required publisher files and the locally converted files OneSpeech loads for inference are present and verified. Present files do not trigger network requests. Each new store verifies disk bytes again; having a directory with a plausible filename is not enough. Let OneSpeech populate the cache rather than guessing its internal file layout.
Use ModelStore.PullAsync when you want exactly one model rather than the recognizer plus its possible timing and speaker models. Its result gives you a verified directory and records of the model’s source and license. The speaker-only variation uses an explicit speaker model ID with PrefetchAsync; that prepares only that model. Neither fetch operation records audio or performs recognition.
Preparation does not accept a publisher’s gated-model terms for you. Models with license terms that exclude them from the defaults must be explicitly selected and come from their publisher. Handle any required license acceptance separately before deployment; do not assume that possession of a model ID grants download or redistribution rights.
Cancellation leaves already-complete files available, while an incomplete transfer is removed. After an interrupted process, the next pull restarts a leftover temporary download rather than resuming its byte range. For a reliable offline rollout, allow preparation to complete and exercise your actual operation with network access unavailable before distributing the application.