در C #، من شما اموزش خواهم داد چگونه یک برنامه ایجاد کنید صدای ضبط شده پخش کند (میکروفون) استفاده 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:
3, Import System.Runtime.InteropServices namespace.
4. Now, in your code module, create a function named record that will access the winmm.dll.
5.For record button for Button1, put this code below.
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.
We used the Play function in Audio to play the saved file in C Directory, the mic.wav, that we recorded its sound earlier.