Hi, welcome back in this video, you learn how to write a script which records all audio from the computer,
a microphone to be able to record audio from the microphone.
We need to use a third party library.
The third party library we will use in this video is called sound device, so you need to install that.
PIP install sound device, and we will also use.
A function from Spy, another part of the library saw from sci fi dots, Io does wave.
File you need to import rights, right, is the methods which will arrive the final audio in an actual
and b free or WAV file.
So we need to install side by as well.
People install side point.
And then we ready to coat, first of all, we want to define some parameters of the all do we want to
generate, for example, how many seconds do we want to record, let's say, five of an f s, which
is a variable.
And it stands for frame per seconds.
Or you can also say f s of frames per second.
A commonly used value for this is four for 100 or so frames per second.
It's also referred to as the sampling rate.
So this is a sampling rate and the units are also referred to as Hertz.
With these two parameters, we ready now to start the recording and we're going to save that in a variable.
And we use sound device.
The library that Rec so recommends recording frames is equal to so how many frames with a complete recording
have?
Well, we have five seconds and we have this number of frames per second, so we are looking at second
times.
FFP is so five times that will give us the total number of frames, the sample rate is FFP as that value.
And finally, we have to declare the channels so it could work with to.
It's because we work with one.
It depends on your device.
For me, it works with one, so I'll keep a one there.
If you get an error or try to, then once we start recording, we want to use a method called wait so
that we will wait until the recording is finished.
And finally, we use of rights that method to write the audio in a file path.
So let's say outputs that MP three.
And here we also need to declare the features and the actual.
Audio, which is stored in my recording valuable.
And we ready to run the coup now.
So I'm going to right click on the wrong man.
It should take five seconds.
It's recording now.
So outputs Dot MP three is there.
I'll try to open it now by going to the actual folder where that is.
And let's listen to it.
It's not working on my computer, so if you are on Mac, it will not work right away because you have
to go to the Apple, I can go to system preferences and then go to security and privacy and then to
the privacy settings, and then you want to go to the microphone and give permission to the IDG.
That's your music.
I'm using my charm.
So I want to select that box, quit and or open platform.
So because we are recording the audio front porch charm on windows, you shouldn't have a problem with
this.
So now I'll try to run the code again.
It's recording one two three one two three one two three.
And so let's see the file again.
It's recording one two three one six three one two three.
So now it works.
Before I close the video, I just want to show something else.
So you understand how this works.
So my recording is actually a non-point array.
Then we write, That's a number, right?
Using the right method because sci fi works with Nampai arrays, so that's another area I can show you.
That's by printing it.
So I can print it out here.
You will see how it looks like.
So it's a novel array.
It contains the Alduan s numbers.
So the sample rates now it's zero zero because the recording has not started yet here.
But if you print it again after you wait with the way to methods, then you'll see we will have another
non-player with actual values, non-zero values.
So now it's recording, and that's the final non-poor array.
You see, it has some values this time because that was empty and that is with actual values.
So let me command those out, and that's the complete course.
Thanks a lot.
I'll talk to you later.