Recording audio from a microphone in .NET or C# applications can be more challenging than it seems. Whether you're building voice-enabled apps, real-time speech-to-text, or accessibility features, capturing clear, high-quality audio in the correct format is crucial.
This guide explains how to record microphone audio in C# and .NET using PvRecorder: a lightweight, cross-platform .NET audio recording library that captures raw PCM audio frames for any speech recognition, voice command, or audio processing workflow.
If you need to play audio in your .NET application, check out PvSpeaker. Refer to the PvSpeaker .NET Quick Start guide and the PvSpeaker .NET API docs for more detailed info.
Recording Audio in .NET with PvRecorder
Before we begin, make sure your system meets the minimum .NET version requirements for your platform:
- Windows (x86_64): .NET Framework 4.6.1+, .NET Standard 2.0+, or .NET Core 3.0+
- macOS (x86_64): .NET Standard 2.0+ or .NET Core 3.0+
- macOS (arm64), Windows (arm64), Linux (x86_64), Raspberry Pi (3, 4, 5): .NET 6.0+
1. Install the NuGet Package
Install the PvRecorder NuGet package:
2. Initialize PvRecorder
Pass in the required frame length for your processing engine or logic. Picovoice engines typically require a frame length of 512:
3. Start Audio Capture
Call Start() to begin recording audio:
4. Capture PCM Audio Frames
After starting the recorder, continuously read audio frames inside a loop:
Each frame is a short[] array containing raw 16-bit PCM samples that you can feed into your audio processing logic, speech recognizer, or write to a file.
5. Stop & Release Resources
To stop recording audio, call Stop(). If you no longer need PvRecorder, call Dispose() to free memory:
Complete .NET Audio Recording Example
Here's a complete .NET console example that records audio from the default microphone, prints the frame length read, and stops on Enter.
This is a simplified example but contains all the essential components to demonstrate audio recording functionality. If you'd like to see a complete working project, check out the PvRecorder .NET Demo on GitHub.
This tutorial uses the following package:
Explore our documentation for more details:
Next Steps
Now that you know how to record audio, you can add the speech recognition features your .NET application needs:
- Porcupine Wake Word: custom wake words so your app can "wake up" to a configured phrase.
- Rhino Speech-to-Intent: custom voice commands so your app can understand what a user is saying, and perform appropriate response.
- Cheetah Streaming Speech-to-Text: real-time transcription so your app can transcribe speech in real time.







