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

PvSpeaker
.NET API

API Reference for the PvSpeaker .NET SDK (NuGet)


namespace: Pv


PvSpeaker

public class PvSpeaker : IDisposable { }

Class for PvSpeaker.


PvSpeaker.PvSpeaker()

public PvSpeaker(
int sampleRate,
int bitsPerSample,
int bufferSizeSecs = 20,
int deviceIndex = -1)

PvSpeaker constructor.

Parameters

  • sampleRate int : The sample rate of the audio to be played.
  • bitsPerSample int : The number of bits per sample of the audio to be played.
  • deviceIndex int : The index of the audio device to play audio from. A value of (-1) will use the default audio device.
  • bufferSizeSecs int : The size in seconds of the internal buffer used to buffer PCM data - i.e. internal circular buffer will be of size sampleRate * bufferSizeSecs.

Returns

  • PvSpeaker: An instance of PvSpeaker.

Throws

  • PvSpeakerException: If an error occurs while creating an instance of PvSpeaker.

PvSpeaker.Dispose()

public void PvSpeaker Dispose()

Frees memory used by the PvSpeaker instance.


PvSpeaker.GetAvailableDevices()

public static string[] GetAvailableDevices()

Gets a list of the available audio output devices on the current system.

Returns

  • string[]: An array of strings containing the names of the audio devices.

Throws

  • PvSpeakerException: If an error occurs while getting audio device info.

PvSpeaker.Start()

public void Start()

Starts the audio output device. Should be called before making any calls to Write(), Flush(), or Stop().

Throws

  • PvSpeakerException: If an error occurs while starting the audio device.

PvSpeaker.Stop()

public void Stop()

Stops the audio output device. Should only be called after a successful call to Start().

Throws

  • PvSpeakerException: If an error occurs while stopping the audio device.

PvSpeaker.Write()

public int Write(byte[] pcm)

Synchronous call to write PCM data to the internal circular buffer for audio playback. Only writes as much PCM data as the internal circular buffer can currently fit, and returns the number of samples that were successfully written. Call between Start() and Stop().

Parameters

  • pcm byte[] : PCM data to be played.

Returns

  • int: Number of samples that were successfully written.

Throws

  • PvSpeakerException: If an error occurs while writing audio data.

PvSpeaker.Flush()

public int Flush(byte[] pcm = null)

Synchronous call to write PCM data to the internal circular buffer for audio playback. This call blocks the thread until all PCM data has been successfully written and played. Call between Start() and Stop().

Parameters

  • pcm byte[] : Optional PCM data to be played.

Returns

  • int: Number of samples that were successfully written.

Throws

  • PvSpeakerException: If an error occurs while flushing audio data.

PvSpeaker.WriteToFile()

public void WriteToFile(string outputPath)

Writes PCM data passed to PvSpeaker to a specified WAV file.

Throws

  • PvSpeakerException: If an error occurs while writing to the output file.

PvSpeaker.IsStarted

public bool IsStarted { get; }

Gets whether the speaker has started and is available to receive PCM data or not.


PvSpeaker.SampleRate

public int SampleRate { get; private set; }

Gets the sample rate matching the value passed to the constructor.


PvSpeaker.BitsPerSample

public int BitsPerSample { get; private set; }

Gets the bits per sample matching the value passed to the constructor.


PvSpeaker.BufferSizeSecs

public int BufferSizeSecs { get; private set; }

Gets the buffer size in seconds matching the value passed to the constructor.


PvSpeaker.SelectedDevice

public string SelectedDevice { get; private set; }

Gets the current selected audio device.


PvSpeaker.Version

public string Version { get; private set; }

Gets the current version of the library.


PvSpeakerException

public class PvSpeakerException : Exception { }

Exception thrown if an error occurs within PvSpeaker.

Exceptions:

public class PvSpeakerMemoryException : PvSpeakerException { }
public class PvSpeakerInvalidArgumentException : PvSpeakerException { }
public class PvSpeakerInvalidStateException : PvSpeakerException { }
public class PvSpeakerBackendException : PvSpeakerException { }
public class PvSpeakerDeviceAlreadyInitializedException : PvSpeakerException { }
public class PvSpeakerDeviceNotInitializedException : PvSpeakerException { }
public class PvSpeakerIOException : PvSpeakerException { }
public class PvSpeakerRuntimeException : PvSpeakerException { }

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
PvSpeaker .NET API
  • PvSpeaker
  • PvSpeaker()
  • Dispose()
  • GetAvailableDevices()
  • Start()
  • Stop()
  • Write()
  • Flush()
  • WriteToFile()
  • IsStarted
  • SampleRate
  • BitsPerSample
  • BufferSizeSecs
  • SelectedDevice
  • Version
  • PvSpeakerException
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.