VoiceHeuristics 1.0.0
dotnet add package VoiceHeuristics --version 1.0.0
NuGet\Install-Package VoiceHeuristics -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VoiceHeuristics" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VoiceHeuristics" Version="1.0.0" />
<PackageReference Include="VoiceHeuristics" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VoiceHeuristics --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VoiceHeuristics, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VoiceHeuristics@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VoiceHeuristics&version=1.0.0
#tool nuget:?package=VoiceHeuristics&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
VoiceHeuristics
Context-aware adjustments for speech-to-text text before it is inserted at the cursor. Handles filler-word stripping, sentence continuation, capitalisation, punctuation correction, and spacing — so dictated text reads naturally no matter where the caret is.
Installation
dotnet add package VoiceHeuristics
Quick start
using VoiceHeuristics;
string leftContext = textBeforeCaret; // everything left of the caret
string rightContext = textAfterCaret; // everything right of the caret
string adjusted = VoiceInsertionHeuristics.Apply(leftContext, rawSpeechText, rightContext);
// Insert `adjusted` at the caret instead of rawSpeechText
What it does
VoiceInsertionHeuristics.Apply() runs the following heuristics in order:
| # | Heuristic | Example |
|---|---|---|
| 0 | Filler-word stripping — removes "uh", "uhh", "um", "umm" (any case) from the start, middle, and end of the text. Filler-only remnants ("Yeah.", "Yep.") are discarded entirely. | "Uh, do this" → "Do this" |
| 1 | Sentence continuation — if the left context ends with a lowercase letter, comma, open paren, semicolon, or dash, the first word of the incoming text is lowercased (unless it's a special token). | "add a " + "New item." → "add a new item." |
| 2 | Mid-sentence insertion — if the right context starts with a lowercase letter or ), trailing periods are stripped to avoid broken punctuation. |
inserting before " years ago" → "Four score and twenty" (no period) |
| 2b | Punctuation double-up prevention — if the right context starts with ., ,, ;, !, ?, or :, the inserted text's trailing sentence punctuation is removed. |
inserting before ", which" → "hello" not "hello." |
| 3 | Trailing punctuation correction — specific high-precision rewrites (e.g. text ending with "this" gets a colon appended). |
"it looks like this." → "it looks like this: " |
| 4 | Trailing space — when the right context starts with a non-whitespace character (other than ) or sentence punctuation), a space is appended so the inserted text doesn't run into the next word. |
inserting before "years" → "twenty " |
| 5 | Post-digit capitalisation — if the left context ends with a digit, the first word of the incoming text is lowercased and a separating space is prepended if needed. | "step 6" + "And then" → " and then" |
Special-case tokens (never lowercased)
- The pronoun
Iand its contractions (I'm,I've,I'll,I'd, …) - Words containing two or more uppercase letters (acronyms:
API,URL; CamelCase:JavaScript,iPhone) - Words containing a digit (
3D,v2,R2D2)
API reference
VoiceInsertionHeuristics.Apply
public static string Apply(
string leftContext,
string incomingText,
string rightContext = "")
| Parameter | Description |
|---|---|
leftContext |
Text to the left of the insertion caret (text[..caretIndex]). |
incomingText |
Raw text from the speech recogniser. |
rightContext |
Text to the right of the caret (text[caretIndex..]). Omit or pass "" when appending at the end. |
Returns the adjusted string to insert.
Individual helper methods (all public static)
These are exposed so callers can unit-test or compose heuristics independently.
| Method | Purpose |
|---|---|
StripFillerWords(text) |
Removes uh/um filler words. |
IsSentenceContinuation(leftContext) |
true when left context signals a continuing sentence. |
LowercaseFirstWordIfNotSpecial(text) |
Lowercases first word unless it's a special token. |
CapitalizeFirstWordIfNotSpecial(text) |
Uppercases first word unless it's a special token. |
IsSpecialCaseWord(word) |
true for I, I'* contractions, acronyms, CamelCase, digit-containing words. |
ApplyTrailingPunctuationFixes(text) |
Conservative trailing-punctuation rewrites. |
IsRightContextMidSentence(rightContext) |
true when right context starts with a lowercase letter or ). |
IsRightContextStartsWithPunctuation(rightContext) |
true when right context starts with . , ; ! ? :. |
IsRightContextRequiresTrailingSpace(rightContext) |
true when a trailing space should be appended. |
StripTrailingPeriods(text) |
Removes one trailing .. |
StripTrailingSentencePunctuation(text) |
Removes one trailing . ! ?. |
IsLeftContextEndsWithDigit(leftContext) |
true when left context ends with a digit. |
Requirements
- .NET 10.0 or later
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 86 | 5/5/2026 |