TextToVoice.Engines.SherpaOnnx 0.3.0

dotnet add package TextToVoice.Engines.SherpaOnnx --version 0.3.0
                    
NuGet\Install-Package TextToVoice.Engines.SherpaOnnx -Version 0.3.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="TextToVoice.Engines.SherpaOnnx" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TextToVoice.Engines.SherpaOnnx" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="TextToVoice.Engines.SherpaOnnx" />
                    
Project file
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 TextToVoice.Engines.SherpaOnnx --version 0.3.0
                    
#r "nuget: TextToVoice.Engines.SherpaOnnx, 0.3.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 TextToVoice.Engines.SherpaOnnx@0.3.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=TextToVoice.Engines.SherpaOnnx&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=TextToVoice.Engines.SherpaOnnx&version=0.3.0
                    
Install as a Cake Tool

TextToVoice.Engines.SherpaOnnx

Embedded ONNX inference engine for TextToVoice. Runs Piper VITS and Kokoro models directly in-process — no external executables needed.

Installation

dotnet add package TextToVoice.Engines.SherpaOnnx

Download a pre-converted model from sherpa-onnx releases (look for vits-piper-* archives).

Quick Start

using TextToVoice.Engines.SherpaOnnx;

var options = new SherpaOnnxOptions
{
    ModelPath = "/path/to/en_US-amy-low.onnx",
    // tokens.txt and espeak-ng-data are auto-detected from the model directory
};

using var engine = new SherpaOnnxEngine(options);

await engine.SpeakAsync("Hello world");
await engine.SaveToFileAsync("Hello world", "output.wav");

// Multi-speaker models
engine.SetVoice("0");              // by speaker ID
engine.SetVoice("en_US-amy#2");    // by modelname#id format

Configuration

var options = new SherpaOnnxOptions
{
    ModelPath = "/path/to/voice.onnx",   // required
    TokensPath = null,                    // auto-detected from model directory
    DataDir = null,                       // auto-detected (espeak-ng-data)
    SpeakerId = 0,                        // for multi-speaker models
    LengthScale = 1.0f,                  // speech speed
    NumThreads = 1,                       // ONNX inference threads
    LeadingSilenceMs = 150,              // silence before playback (0 to disable)
    Normalize = true,                     // peak-normalise each line before volume
    VoicesPath = null,                    // set to a Kokoro voices.bin to load a Kokoro model
};

Several voices from one engine

Pass a SherpaOnnxVoice per call. One multi-speaker model (for example libritts_r, 904 speakers) can then voice a whole cast, from several threads at once, without touching the engine's default voice:

var helm = new SherpaOnnxVoice(SpeakerId: 40);
var pilot = new SherpaOnnxVoice(SpeakerId: 120, Speed: 1.1f, Volume: 0.8f);

byte[] wav = await engine.SynthesizeToAudioAsync("Helm, aye.", helm);

// Raw mono samples in [-1, 1], for feeding an audio engine directly.
SynthesizedAudio audio = engine.Synthesize("Two bandits on my six.", pilot);

Calls into the model are serialized, so parallel calls are safe but do not run faster.

Kokoro support covers the English models (for example kokoro-en-v0_19). The multilingual Kokoro v1.0 models also need a lexicon and dictionary directory, which are not exposed yet.

Since 0.3.0, SetVolume and SherpaOnnxVoice.Volume change the output level. Earlier versions normalised every line to full scale after applying volume, so volume had no effect.

Requirements

  • .NET 10+
  • ONNX voice model (Piper VITS format with sherpa-onnx metadata)

License

MIT

Product 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.

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
0.3.0 182 10/24/2026
0.1.0 236 3/13/2026
0.1.0-alpha.0.19 83 5/14/2026
0.1.0-alpha.0.18 108 5/10/2026
0.1.0-alpha.0.17 91 5/10/2026
0.1.0-alpha.0.16 109 3/14/2026