Picovoice Wordmark
Start Building
Introduction
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryPicovoice picoLLMGPTQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-TextWhisper Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice Cheetah
FAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryAmazon PollyAzure TTSElevenLabsOpenAI TTSPicovoice Orca
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidCNode.jsPythoniOSWeb
SummaryPicovoice EaglepyannoteSpeechBrainWeSpeaker
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice FalconAmazon TranscribeAzure Speech-to-TextGoogle Speech-to-Textpyannote
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeRustUnityWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustUnityWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiRustWebWindows
AndroidC.NETiOSNode.jsPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
Introduction
C.NETNode.jsPython
C.NETNode.jsPython
FAQGlossary

Audio Output
.NET Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Windows (x86_64, arm64)
  • Raspberry Pi (3, 4, 5)

Requirements

.NET Framework 4.6.1+ / .NET Standard 2.0+ / .NET Core 3.0+:

  • Windows (x86_64)

.NET Standard 2.0+ / .NET Core 3.0+:

  • macOS (x86_64)

.NET 6.0+:

  • macOS (arm64)
  • Windows (arm64)
  • Linux (x86_64)
  • Raspberry Pi (3, 4, 5)

Quick Start

Setup

  1. Install .NET.

  2. Install the PvSpeaker NuGet package in Visual Studio or using the .NET CLI:

dotnet add package PvSpeaker

Usage

Initialize and start PvSpeaker:

using Pv;
var speaker = new PvSpeaker(
sampleRate: 22050,
bitsPerSample: 16);
speaker.Start();

Write PCM data to the speaker:

public static byte[] GetNextAudioFrame() { }
int writtenLength = speaker.Write(GetNextAudioFrame());

Note: the Write() method only writes as much PCM data as the internal circular buffer can currently fit, and returns the number of samples that were successfully written.

When all frames have been written, run Flush() to wait for all buffered PCM data (i.e. previously buffered via Write()) to be played:

int flushedLength = speaker.Flush();

Note: calling Flush() with PCM data as an argument will both write that PCM data and wait for all buffered PCM data to finish.

public static byte[] GetRemainingAudioFrames() { }
int flushedLength = speaker.Flush(GetRemainingAudioFrames());

To stop the audio output device, run Stop():

speaker.Stop();

Once you are done, free the resources acquired by PvSpeaker. You do not have to call Stop() before Dispose():

speaker.Dispose();

To have resources freed immediately after use without explicitly calling the Dispose() function, wrap PvSpeaker in a using statement:

using (var speaker = new PvSpeaker(sampleRate: 22050, bitsPerSample: 16)) {
// PvSpeaker usage
}

Selecting an Audio Device

To print a list of available audio devices:

string[] devices = PvSpeaker.GetAudioDevices();

The index of the device in the returned list can be used in Create() to select that device for audio playback:

var speaker = new PvSpeaker(
sampleRate: 22050,
bitsPerSample: 16,
deviceIndex: 2);

Demo

For the PvSpeaker .NET SDK, we offer a demo application that demonstrates how use PvSpeaker to play audio from an audio file (.wav).

Setup

  1. Clone the repository:
git clone --recurse-submodules https://github.com/Picovoice/pvspeaker.git
  1. Build the project:
cd pvspeaker/demo/dotnet
dotnet build

Usage

To show the available audio devices run:

dotnet run -- --show_audio_devices

To run the demo, give it a file to play audio from:

dotnet run -- --input_wav_path ${INPUT_WAV_FILE}

You can also select the audio device index to use for playback (use --show_audio_devices to see options):

dotnet run -- --input_wav_path ${INPUT_WAV_FILE} --audio_device_index ${DEVICE_INDEX}

For more information about our PvSpeaker demo, head over to our GitHub repository.

Resources

Package

  • PvSpeaker on NuGet

API

  • PvSpeaker .NET API Docs

GitHub

  • PvSpeaker .NET SDK on GitHub
  • PvSpeaker .NET Demo on GitHub

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Audio Output .NET Quick Start
  • Platforms
  • Requirements
  • Quick Start
  • Setup
  • Usage
  • Selecting an Audio Device
  • Demo
  • Setup
  • Usage
  • Resources
Voice AI
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Orca Text-to-Speech
  • Koala Noise Suppression
  • Eagle Speaker Recognition
  • Falcon Speaker Diarization
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Local LLM
  • picoLLM Inference
  • picoLLM Compression
  • picoLLM GYM
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
  • Playground
Sales & Services
  • Consulting
  • Foundation Plan
  • Enterprise Plan
  • Enterprise Support
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • X
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2025 Picovoice Inc.