Today in C#, i will teach you how to create a program that records voice and plays it (microphone) using C#.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application and name your program as microphone.
2. Next, add three buttons named Button1 as record button for recording voice, Button2 as save and stop button, and Button3 for playing the recorded audio. You must design your interface like this:
record("open new Type waveaudio Alias recsound", "", 0, 0);
record("record recsound", "", 0, 0);
The function named record was called here to open a wav audio file that is named as recsound. Then this will record sound as you click the record button. Note: Provide headset with microphone or speaker in your PC or laptop for you to say the words to record.
6. For save and stop button for Button2, put this code below.
The recsound alias that we initialized in the record button was called here. This button will save the recorded audio file and saved into C directory and will named as mic.wav. Then after saving, we close the recorded sound.
7.For play button for Button3, put this code below.