Phrase biasing favors supplied terms without retraining. Whisper supports it; Moonshine does not.
dotnet add package RecursiveAI.OneSpeechOneAudio is a dependency of RecursiveAI.OneSpeech; no separate install is needed.
Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
sample.flac is in the zip.
using OneSpeech; using OneSpeech.Whisper; var clip = OneAudio.Audio.Load("sample.flac", new OneAudio.LoadOptions { SampleRate = 16000, Channels = 1 }); using var model = await WhisperRecognizer.LoadAsync(); var audio = new AudioBuffer(clip.Samples, 16000); Console.WriteLine("Unbiased: " + model.Transcribe(audio, "en").Text); var biased = model.WithPhrases([new Phrase("stuff it into you")]); Console.WriteLine("Biased: " + biased.Transcribe(audio, "en").Text);
Unzip the example, then dotnet run.
Prints:
Unbiased: "'Stuff it into you,' his belly counselled him. Biased: stuff it into you his belly counselled him
The recognized words are unchanged: biasing only changes capitalization and punctuation here, removing the opening quotation marks, comma, closing quote and final period.
sample.flac is the LibriSpeech test-clean clip 1089-134686-0001: “stuff it into you his belly counselled him”. It is included under CC BY 4.0, credited to Vassil Panayotov, Guoguo Chen, Daniel Povey and Sanjeev Khudanpur (source). First use downloads Whisper weights; the phrase list is not a separate trained model.
A nonempty phrase request on Moonshine throws CapabilityNotSupportedException; Whisper rejects explicit numeric phrase weights.
Variations
Remove the phrase list. Replace the biased assignment with this line; the owning model stays alive:
var biased = model.WithPhrases([]);Unbiased: "'Stuff it into you,' his belly counselled him. Biased: "'Stuff it into you,' his belly counselled him.
Related recipes
The short answer
For C# speech recognition with a custom vocabulary, load a Whisper recognizer and call WithPhrases with the names or terms you expect. Transcribe through the returned recognizer. This is contextual biasing, not dictionary replacement, model training, or a promise that a requested word will appear.
The example requests “stuff it into you”, which occurs in the recording. It changes only capitalization and punctuation, not which words are recognized; this is not evidence of improved word recognition.
How do I add a phrase list to speech recognition?
Create Phrase values and pass them to the loaded recognizer’s WithPhrases method, as in the snippet at the top. The wrapper holds an immutable phrase list. It borrows the original model: keep that model alive until transcription and any sessions have finished. Disposing a wrapper does not transfer ownership of the model.
Calling WithPhrases again replaces the list rather than appending to it. An empty list returns the original unbiased recognizer. The original recognizer is never modified, so an application can keep a baseline path alongside a biased path. Wrappers still share the owning model’s concurrency restrictions; separate phrase lists are not separate inference engines.
For Whisper, the list becomes ordinary prompt tokens for each window. It is not a text postprocessor. Qwen3-ASR adds phrases to its existing system context. These two methods reject explicit numeric weights rather than pretending to apply token-score bonuses. The pinned README describes the public API and supported families.
Can I use a custom vocabulary for C# speech to text?
Yes, with a recognizer that advertises biasing support. Whisper, Qwen3-ASR, Parakeet TDT, Nemotron 3.5 ASR and appropriately configured custom graphs support it. Moonshine does not: a nonempty phrase request throws instead of silently ignoring the list. The high-level Speech.Transcribe API does not take a phrase list; use the low-level recognizer or pass the wrapper to a transcription pipeline.
Token-fusion recognizers use a different mechanism from Whisper’s prompts. Parakeet TDT and Nemotron accept a natural-log bonus per token; custom graphs require a phrase encoder for their exact tokenizer. Do not assume that a phrase weight has the same meaning across model families.
Biasing can introduce false alarms. The README specifically warns that Whisper prompt conditioning can substantially increase overall errors and repeat absent terms even when requested-term recall improves. It is not a safe default. Before enabling it for users, compare phrase recall and overall word error rate on your own audio, including recordings where none of the requested terms occur. Keep an unbiased baseline and test the phrase lists your application actually builds. See contextual token scoring for budgets and decoder behavior.