TensorStack.AudioCpp
0.16.0
Prefix Reserved
See the version list below for details.
dotnet add package TensorStack.AudioCpp --version 0.16.0
NuGet\Install-Package TensorStack.AudioCpp -Version 0.16.0
<PackageReference Include="TensorStack.AudioCpp" Version="0.16.0" />
<PackageVersion Include="TensorStack.AudioCpp" Version="0.16.0" />
<PackageReference Include="TensorStack.AudioCpp" />
paket add TensorStack.AudioCpp --version 0.16.0
#r "nuget: TensorStack.AudioCpp, 0.16.0"
#:package TensorStack.AudioCpp@0.16.0
#addin nuget:?package=TensorStack.AudioCpp&version=0.16.0
#tool nuget:?package=TensorStack.AudioCpp&version=0.16.0
TensorStack.AudioCpp
Basic .NET Wrapper API for audio.cpp
Nuget Package
Music Example
Generate music using ACE-Step
using (var backend = new AudioCppBackend(VendorType.Nvidia))
{
await backend.InitializeAsync();
using (var pipeline = new AudioCppPipeline(backend))
{
await pipeline.LoadAsync(new AudioCppOptions
{
Pipeline = "ace_step",
ModelPath = "models/Ace-Step1.5",
Backend = "cuda"
});
AudioTensor audio = await pipeline.GenerateAudioAsync(new GenerateAudioOptions
{
Prompt = "cinematic synth pop with clear vocals",
Prompt2 = "We rise with the morning light",
Duration = 60,
Seed = 420
});
}
}
Speech Example
Generate speech using Kokoro
using (var backend = new AudioCppBackend(VendorType.Nvidia))
{
await backend.InitializeAsync();
using (var pipeline = new AudioCppPipeline(backend))
{
await pipeline.LoadAsync(new AudioCppOptions
{
Pipeline = "kokoro_tts",
ModelPath = "models/Kokoro-82M-GGUF/kokoro-82m-q8_0.gguf",
Backend = "cuda"
});
AudioTensor audio = await pipeline.GenerateAudioAsync(new GenerateAudioOptions
{
Prompt = "Hello from audio.cpp.",
Language = "en-us",
Task = "af_heart"
});
}
}
Speech Recognition Example
Transcribe speech using Parakeet-TDT
using (var backend = new AudioCppBackend(VendorType.Nvidia))
{
await backend.InitializeAsync();
using (var pipeline = new AudioCppPipeline(backend))
{
await pipeline.LoadAsync(new AudioCppOptions
{
Pipeline = "parakeet_tdt",
ModelPath = "models/Parakeet-TDT-0.6B-v3-GGUF/parakeet-tdt-0.6b-v3-q8_0.gguf",
Backend = "cuda"
});
// AudioInput is part of TensorStack.Media
AudioTensor inputAudio = await AudioInput.CreateAsync("speech.wav", sampleRate: 16000, channels: 1);
string text = await pipeline.GenerateTextAsync(new GenerateTextOptions
{
InputAudios = [inputAudio]
});
}
}
Live Speech Recognition Example
Transcribe the microphone as you speak using Voxtral Realtime, the text is returned as it is recognised
using (var backend = new AudioCppBackend(VendorType.Nvidia))
{
await backend.InitializeAsync();
using (var pipeline = new AudioCppPipeline(backend))
{
await pipeline.LoadAsync(new AudioCppOptions
{
Pipeline = "voxtral_realtime",
ModelPath = "models/Voxtral-Mini-4B-Realtime-2602-GGUF/voxtral-mini-4b-realtime-2602-q8_0.gguf",
Backend = "cuda"
});
// AudioCapture is part of TensorStack.Media, cancel stopToken to end the stream
var microphone = AudioCapture.CaptureAsync(sampleRate: 16000, channels: 1, stopToken: stopToken);
await foreach (var text in pipeline.GenerateTextStreamAsync(new GenerateTextOptions(), microphone))
{
Console.Write(text);
}
}
}
Any IAsyncEnumerable<AudioTensor> can be streamed, every chunk must have the same sample rate and channels. IsStreamSupported("asr") checks the loaded model supports it.
Voice Clone Example
Speak in the voice of a reference recording using OmniVoice, the speaker reference is passed in InputAudios
using (var backend = new AudioCppBackend(VendorType.Nvidia))
{
await backend.InitializeAsync();
using (var pipeline = new AudioCppPipeline(backend))
{
await pipeline.LoadAsync(new AudioCppOptions
{
Pipeline = "omnivoice",
ModelPath = "models/OmniVoice-GGUF/omnivoice-q8_0.gguf",
Backend = "cuda"
});
AudioTensor speaker = await AudioInput.CreateAsync("speaker.wav", sampleRate: 24000, channels: 1);
AudioTensor audio = await pipeline.GenerateAudioAsync(new GenerateAudioOptions
{
Prompt = "This is my cloned voice.",
ReferenceText = "The words spoken in speaker.wav.", // Required by some models (OmniVoice, Fish Audio)
InputAudios = [speaker]
});
await audio.SaveAsync("Output.wav");
}
}
Pipelines
AudioCppOptions.Pipeline is the audio.cpp model family, or null to identify the model from its path. Some of the pipelines:
| Use | Pipelines |
|---|---|
| Music | ace_step, minimax_music3, stable_audio, yue2, heartmula |
| Sound effects | stable_audio, moss_soundeffect |
| Speech | kokoro_tts, supertonic, qwen3_tts, voxtral_tts, chatterbox_turbo, omnivoice, fish_audio, voxcpm2, higgs_audio_tts, magpie_tts, neutts |
| Speech recognition | parakeet_tdt, qwen3_asr, canary_asr, cohere_asr, crisperwhisper, granite5asr, vibevoice_asr, voxtral_realtime (live) |
IsTaskSupported checks the tasks of the loaded model (gen, tts, clon, asr etc).
Options
GenerateAudioOptions and GenerateTextOptions are translated to the request options of the loaded model. Values left at their default are not sent, so the audio.cpp model default applies, and only options the loaded model declares are applied.
| Option | Music | Speech |
|---|---|---|
Prompt |
caption or style | text to speak |
Prompt2 |
lyrics | |
Task |
route (text2music, cover, full etc) |
built-in voice |
InputAudios |
source audio | speaker reference |
Any other audio.cpp option can be passed by name, these map 1:1 onto --request-option and --session-option:
new GenerateAudioOptions
{
Prompt = "uplifting house music",
Options = { ["sampler_mode"] = "euler" }
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows10.0.17763 is compatible. |
-
net10.0-windows10.0.17763
- Microsoft.Extensions.Logging (>= 11.0.0)
- TensorStack.Common (>= 0.16.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.