1
00:00:00,690 --> 00:00:08,230
Hi, welcome back in this video, you learn how to write a script which records all audio from the computer,

2
00:00:08,230 --> 00:00:13,140
a microphone to be able to record audio from the microphone.

3
00:00:13,290 --> 00:00:15,270
We need to use a third party library.

4
00:00:15,540 --> 00:00:25,110
The third party library we will use in this video is called sound device, so you need to install that.

5
00:00:26,810 --> 00:00:32,390
PIP install sound device, and we will also use.

6
00:00:33,600 --> 00:00:42,900
A function from Spy, another part of the library saw from sci fi dots, Io does wave.

7
00:00:44,060 --> 00:00:52,760
File you need to import rights, right, is the methods which will arrive the final audio in an actual

8
00:00:53,120 --> 00:00:55,940
and b free or WAV file.

9
00:00:56,480 --> 00:00:58,670
So we need to install side by as well.

10
00:00:58,700 --> 00:01:00,670
People install side point.

11
00:01:07,200 --> 00:01:14,970
And then we ready to coat, first of all, we want to define some parameters of the all do we want to

12
00:01:14,970 --> 00:01:26,730
generate, for example, how many seconds do we want to record, let's say, five of an f s, which

13
00:01:26,730 --> 00:01:27,630
is a variable.

14
00:01:27,990 --> 00:01:31,180
And it stands for frame per seconds.

15
00:01:32,070 --> 00:01:35,610
Or you can also say f s of frames per second.

16
00:01:36,540 --> 00:01:43,140
A commonly used value for this is four for 100 or so frames per second.

17
00:01:43,290 --> 00:01:47,060
It's also referred to as the sampling rate.

18
00:01:47,070 --> 00:01:52,170
So this is a sampling rate and the units are also referred to as Hertz.

19
00:01:52,560 --> 00:02:00,560
With these two parameters, we ready now to start the recording and we're going to save that in a variable.

20
00:02:01,260 --> 00:02:03,780
And we use sound device.

21
00:02:05,320 --> 00:02:17,110
The library that Rec so recommends recording frames is equal to so how many frames with a complete recording

22
00:02:17,110 --> 00:02:17,470
have?

23
00:02:17,740 --> 00:02:25,270
Well, we have five seconds and we have this number of frames per second, so we are looking at second

24
00:02:25,420 --> 00:02:26,140
times.

25
00:02:27,260 --> 00:02:38,720
FFP is so five times that will give us the total number of frames, the sample rate is FFP as that value.

26
00:02:40,280 --> 00:02:44,840
And finally, we have to declare the channels so it could work with to.

27
00:02:44,870 --> 00:02:45,980
It's because we work with one.

28
00:02:45,980 --> 00:02:47,660
It depends on your device.

29
00:02:48,470 --> 00:02:51,770
For me, it works with one, so I'll keep a one there.

30
00:02:52,160 --> 00:03:00,890
If you get an error or try to, then once we start recording, we want to use a method called wait so

31
00:03:00,890 --> 00:03:03,680
that we will wait until the recording is finished.

32
00:03:04,340 --> 00:03:11,750
And finally, we use of rights that method to write the audio in a file path.

33
00:03:11,930 --> 00:03:14,510
So let's say outputs that MP three.

34
00:03:15,260 --> 00:03:20,420
And here we also need to declare the features and the actual.

35
00:03:23,020 --> 00:03:28,150
Audio, which is stored in my recording valuable.

36
00:03:30,600 --> 00:03:33,210
And we ready to run the coup now.

37
00:03:35,570 --> 00:03:37,850
So I'm going to right click on the wrong man.

38
00:03:38,720 --> 00:03:40,880
It should take five seconds.

39
00:03:41,270 --> 00:03:42,380
It's recording now.

40
00:03:48,480 --> 00:03:51,420
So outputs Dot MP three is there.

41
00:03:51,720 --> 00:03:58,620
I'll try to open it now by going to the actual folder where that is.

42
00:03:58,980 --> 00:04:00,780
And let's listen to it.

43
00:04:05,960 --> 00:04:12,020
It's not working on my computer, so if you are on Mac, it will not work right away because you have

44
00:04:12,020 --> 00:04:20,180
to go to the Apple, I can go to system preferences and then go to security and privacy and then to

45
00:04:20,180 --> 00:04:25,400
the privacy settings, and then you want to go to the microphone and give permission to the IDG.

46
00:04:25,940 --> 00:04:26,900
That's your music.

47
00:04:26,900 --> 00:04:28,100
I'm using my charm.

48
00:04:28,400 --> 00:04:32,720
So I want to select that box, quit and or open platform.

49
00:04:33,020 --> 00:04:40,580
So because we are recording the audio front porch charm on windows, you shouldn't have a problem with

50
00:04:40,580 --> 00:04:40,850
this.

51
00:04:41,540 --> 00:04:43,640
So now I'll try to run the code again.

52
00:04:44,540 --> 00:04:47,780
It's recording one two three one two three one two three.

53
00:04:50,310 --> 00:04:52,800
And so let's see the file again.

54
00:04:55,600 --> 00:04:58,810
It's recording one two three one six three one two three.

55
00:04:59,410 --> 00:05:00,430
So now it works.

56
00:05:01,450 --> 00:05:05,770
Before I close the video, I just want to show something else.

57
00:05:05,770 --> 00:05:07,870
So you understand how this works.

58
00:05:08,290 --> 00:05:12,060
So my recording is actually a non-point array.

59
00:05:13,090 --> 00:05:15,370
Then we write, That's a number, right?

60
00:05:15,700 --> 00:05:22,450
Using the right method because sci fi works with Nampai arrays, so that's another area I can show you.

61
00:05:22,450 --> 00:05:24,010
That's by printing it.

62
00:05:24,700 --> 00:05:26,410
So I can print it out here.

63
00:05:26,830 --> 00:05:28,840
You will see how it looks like.

64
00:05:29,110 --> 00:05:31,060
So it's a novel array.

65
00:05:31,070 --> 00:05:35,410
It contains the Alduan s numbers.

66
00:05:35,530 --> 00:05:43,090
So the sample rates now it's zero zero because the recording has not started yet here.

67
00:05:43,570 --> 00:05:52,450
But if you print it again after you wait with the way to methods, then you'll see we will have another

68
00:05:52,630 --> 00:05:56,890
non-player with actual values, non-zero values.

69
00:05:57,520 --> 00:06:00,630
So now it's recording, and that's the final non-poor array.

70
00:06:00,640 --> 00:06:08,050
You see, it has some values this time because that was empty and that is with actual values.

71
00:06:08,710 --> 00:06:11,620
So let me command those out, and that's the complete course.

72
00:06:11,740 --> 00:06:12,310
Thanks a lot.

73
00:06:12,490 --> 00:06:13,450
I'll talk to you later.

