1
00:00:00,120 --> 00:00:06,840
Hi, welcome back and this video, I'll show you how to load all the files in Python and how to process

2
00:00:06,840 --> 00:00:14,460
them with processing, I mean, things like reversing the old you, slicing the audio, merging different

3
00:00:14,460 --> 00:00:21,410
audio tracks, increasing the volume of audio, etc. So all these you can do via Python.

4
00:00:21,420 --> 00:00:25,590
So I have this empty ripple here with an empty main that's pure file.

5
00:00:25,770 --> 00:00:31,740
But I do have this beat that wave file, which you can probably open its own ripple.

6
00:00:31,740 --> 00:00:38,430
If not, click here and download it just to listen what this audio is about, but I can play it on a

7
00:00:38,430 --> 00:00:38,760
ripple.

8
00:00:41,990 --> 00:00:43,490
It's a three seconds audio.

9
00:00:48,050 --> 00:00:53,960
So first, let's get some basic info about this audio file and to do that with Python.

10
00:00:53,990 --> 00:01:00,860
First, we have to load these audio file as sort of an audio object type in Python.

11
00:01:01,190 --> 00:01:09,890
And you can work with audio objects in Python using the P y dub library, which I'm going to install

12
00:01:11,180 --> 00:01:13,040
if you have forked this ripple.

13
00:01:13,070 --> 00:01:14,480
This should be installed by default.

14
00:01:14,930 --> 00:01:16,100
So that package?

15
00:01:18,080 --> 00:01:27,560
And once I stole that package, I can import from P y dub import all segment.

16
00:01:28,460 --> 00:01:34,160
This is a central class that allows us to create all the objects.

17
00:01:34,400 --> 00:01:38,920
So to create an audio object now you can see audio equals two.

18
00:01:38,930 --> 00:01:46,340
So a variable or you can just say original to denote the original audio object because we're going to

19
00:01:46,880 --> 00:01:50,390
create other old use based on this original object.

20
00:01:50,720 --> 00:01:52,340
So we're going to create a reverse.

21
00:01:52,340 --> 00:01:52,730
I'll do it.

22
00:01:52,740 --> 00:02:00,200
We're going to create another all day, which is only the first two seconds of these three second long

23
00:02:00,470 --> 00:02:01,730
audio and so on.

24
00:02:02,030 --> 00:02:09,229
So the original is audio segment, and you don't do that as you may expect, but use.

25
00:02:11,110 --> 00:02:20,470
A methods, depending on what type of all your file formats you have, in our case, we have a W a V,

26
00:02:20,710 --> 00:02:26,170
so I'm going to use from W a v a method of this class.

27
00:02:26,890 --> 00:02:39,040
And if you give the path to the file which is beat that w a V that should create this original all the

28
00:02:39,040 --> 00:02:47,350
object type we can print the type of this original and also print original just to see what we have.

29
00:02:47,770 --> 00:02:48,220
Run.

30
00:02:48,520 --> 00:02:48,820
All right.

31
00:02:48,820 --> 00:02:50,280
So original, it's not defines.

32
00:02:51,390 --> 00:02:52,750
Yeah, I got a typo here.

33
00:02:53,290 --> 00:02:53,680
Sorry.

34
00:02:54,540 --> 00:02:55,230
Run again.

35
00:02:55,240 --> 00:02:57,960
And so this is the type this one here.

36
00:02:57,970 --> 00:02:59,640
So it's in all these segments.

37
00:02:59,650 --> 00:03:07,180
So this method outputs all this segment instances, and this is how the object looks like.

38
00:03:07,180 --> 00:03:09,160
But that's boring.

39
00:03:09,160 --> 00:03:12,370
So let's do some fun now with audio.

40
00:03:12,790 --> 00:03:17,980
So from the original, we could create another object and hold the object.

41
00:03:18,390 --> 00:03:28,120
Reverse, for example, equals to original dot versus a methods of all the object types.

42
00:03:28,900 --> 00:03:30,370
So reverse.

43
00:03:30,430 --> 00:03:35,440
And this audio doesn't get any arguments and required arguments.

44
00:03:35,740 --> 00:03:36,700
So this is enough.

45
00:03:36,910 --> 00:03:38,440
But how do we see?

46
00:03:38,440 --> 00:03:40,630
How do we listen to this reverse audio?

47
00:03:40,930 --> 00:03:51,880
Well, you can refer to that variable and apply the export methods and then specify a path to the file.

48
00:03:53,170 --> 00:04:03,010
So in my case, I'm writing reverse that w a v run and a new file has been created here on my directory.

49
00:04:03,490 --> 00:04:05,380
If I click that play.

50
00:04:09,610 --> 00:04:16,600
If you have a good year, then you'll be able to distinguish the difference, you see the original one.

51
00:04:25,290 --> 00:04:27,910
Yeah, so they are different right now.

52
00:04:28,420 --> 00:04:34,180
Let's talk for a while and see where did I get these methods and that methods?

53
00:04:34,690 --> 00:04:39,540
Well, for a complete list of methods, you can apply to this.

54
00:04:39,550 --> 00:04:47,560
All these segments object instance, you can do print the original run.

55
00:04:48,250 --> 00:04:50,830
And so these are the methods.

56
00:04:51,190 --> 00:04:57,610
So of course, we cannot go through all of them, but we're going to go through the most important ones

57
00:04:57,610 --> 00:04:58,810
that you will be using.

58
00:04:59,470 --> 00:05:02,350
So reverse we tried reverse.

59
00:05:02,350 --> 00:05:09,700
If you go to our, you see these are in alphabetical order, you see reverse here and we also use export.

60
00:05:10,060 --> 00:05:10,840
This one in here.

61
00:05:12,130 --> 00:05:15,520
There are some things, though, which are not methods.

62
00:05:15,670 --> 00:05:21,490
For example, if you want to extract only the first two seconds of the original audio file, the way

63
00:05:21,490 --> 00:05:30,400
to do that is so let me comment that out by using least slicing syntax.

64
00:05:30,760 --> 00:05:40,870
So let's say first to another variable, which will hold the two seconds all your object first to its

65
00:05:40,870 --> 00:05:45,790
original from the second zero two.

66
00:05:46,030 --> 00:05:50,860
You don't write two, but you write 2000 because this expects milliseconds.

67
00:05:51,700 --> 00:05:53,560
You can also omits the zero.

68
00:05:53,590 --> 00:05:54,610
That's not necessary.

69
00:05:55,210 --> 00:05:56,220
I prefer to keep it.

70
00:05:56,230 --> 00:06:05,740
It makes the code more readable and first to that exports to save all the objects to a file on disk.

71
00:06:06,190 --> 00:06:09,630
Let's say first to that way file run.

72
00:06:10,030 --> 00:06:11,730
And this is a file generated.

73
00:06:12,070 --> 00:06:14,170
You see, it's two seconds long.

74
00:06:14,650 --> 00:06:17,470
The original one was three seconds.

75
00:06:18,510 --> 00:06:18,780
So.

76
00:06:22,230 --> 00:06:32,310
Right now, if you want to see the length of and all the objects you can use, the Python Lend function

77
00:06:33,600 --> 00:06:42,060
so original you run and you'll see it's something like three thousand five hundred sixty seven milliseconds.

78
00:06:43,160 --> 00:06:50,150
So which means it's around 3.5, six, seven seconds here on Ripple, it shows.

79
00:06:50,240 --> 00:06:51,080
S and No.

80
00:06:51,350 --> 00:06:55,490
S an integer, so three seconds, but that's all we're Apple shows.

81
00:06:55,490 --> 00:07:01,160
It's on the audio player to merge two audio files.

82
00:07:01,400 --> 00:07:02,810
You can do this.

83
00:07:03,200 --> 00:07:06,590
Merged equals to original plus.

84
00:07:07,870 --> 00:07:12,610
Reversed, so we are merging that to that.

85
00:07:13,030 --> 00:07:21,040
In other words, we are a pending reversed two original so original will be the first reverse will come

86
00:07:21,040 --> 00:07:21,640
after that.

87
00:07:23,140 --> 00:07:28,600
Let's export it to a file on disk and to listen to it.

88
00:07:29,170 --> 00:07:30,100
It's a merged.

89
00:07:30,220 --> 00:07:37,120
You see, it's seven seconds now because each of those audio files were 3.5 seconds each.

90
00:07:45,330 --> 00:07:46,140
Right, sounds good.

91
00:07:47,160 --> 00:07:52,770
You could also add an empty a silence between these two.

92
00:07:53,250 --> 00:07:54,510
To do that, you could do.

93
00:07:57,020 --> 00:08:01,070
I'll just segment that's silent.

94
00:08:02,810 --> 00:08:10,460
Plus that silent for, let's say, a thousand milliseconds, so one second, let's override the existing

95
00:08:10,820 --> 00:08:12,290
file, so run.

96
00:08:14,380 --> 00:08:17,170
And listen to merge that wave.

97
00:08:17,410 --> 00:08:19,330
So you see, it's eight seconds now.

98
00:08:23,760 --> 00:08:26,130
One second silence, then starts again.

99
00:08:31,550 --> 00:08:32,450
One more time.

100
00:08:38,280 --> 00:08:38,580
Right.

101
00:08:39,090 --> 00:08:48,270
So that is how you keep adding all your files, appending audio files to other audio files.

102
00:08:48,540 --> 00:08:51,180
You can also use a multiplication operator.

103
00:08:51,570 --> 00:08:55,890
So let's say you want two original tracks before.

104
00:08:56,070 --> 00:09:01,410
So one after another and then a silence and then the reverse all do.

105
00:09:01,530 --> 00:09:02,490
So run that.

106
00:09:03,090 --> 00:09:05,610
No, it's going to be something like 11 seconds.

107
00:09:06,060 --> 00:09:07,980
Yeah, it's 11 seconds.

108
00:09:21,310 --> 00:09:25,930
I'm not a music expert, but this is sounding good to me so far.

109
00:09:26,410 --> 00:09:31,450
And lastly, I would like to show you how to increase the volume of your audio.

110
00:09:31,690 --> 00:09:37,720
Let's say we want the reversed port to be 15 more decibels.

111
00:09:37,990 --> 00:09:44,670
To do that, what we can do is, we can say, reversed equals to reverse.

112
00:09:44,680 --> 00:09:53,380
So the original plus 15 as intuitive as that, so now reversed is has a higher volume.

113
00:09:53,710 --> 00:09:56,050
And then we add reverse here.

114
00:09:56,050 --> 00:09:59,770
So reverse at this point will have a higher volume.

115
00:10:01,000 --> 00:10:06,370
Therefore, we ready to execute this and listen to the merged file.

116
00:10:18,530 --> 00:10:25,510
Yeah, so I think you were able to listen to tell that the volume of the lost part was higher.

117
00:10:26,140 --> 00:10:27,820
And that is the complete code.

118
00:10:28,420 --> 00:10:32,590
Let's have some more fun with music of the falls in the next video.

119
00:10:32,740 --> 00:10:33,180
Thank you.

