Hi, welcome back and this video, I'll show you how to load all the files in Python and how to process
them with processing, I mean, things like reversing the old you, slicing the audio, merging different
audio tracks, increasing the volume of audio, etc. So all these you can do via Python.
So I have this empty ripple here with an empty main that's pure file.
But I do have this beat that wave file, which you can probably open its own ripple.
If not, click here and download it just to listen what this audio is about, but I can play it on a
ripple.
It's a three seconds audio.
So first, let's get some basic info about this audio file and to do that with Python.
First, we have to load these audio file as sort of an audio object type in Python.
And you can work with audio objects in Python using the P y dub library, which I'm going to install
if you have forked this ripple.
This should be installed by default.
So that package?
And once I stole that package, I can import from P y dub import all segment.
This is a central class that allows us to create all the objects.
So to create an audio object now you can see audio equals two.
So a variable or you can just say original to denote the original audio object because we're going to
create other old use based on this original object.
So we're going to create a reverse.
I'll do it.
We're going to create another all day, which is only the first two seconds of these three second long
audio and so on.
So the original is audio segment, and you don't do that as you may expect, but use.
A methods, depending on what type of all your file formats you have, in our case, we have a W a V,
so I'm going to use from W a v a method of this class.
And if you give the path to the file which is beat that w a V that should create this original all the
object type we can print the type of this original and also print original just to see what we have.
Run.
All right.
So original, it's not defines.
Yeah, I got a typo here.
Sorry.
Run again.
And so this is the type this one here.
So it's in all these segments.
So this method outputs all this segment instances, and this is how the object looks like.
But that's boring.
So let's do some fun now with audio.
So from the original, we could create another object and hold the object.
Reverse, for example, equals to original dot versus a methods of all the object types.
So reverse.
And this audio doesn't get any arguments and required arguments.
So this is enough.
But how do we see?
How do we listen to this reverse audio?
Well, you can refer to that variable and apply the export methods and then specify a path to the file.
So in my case, I'm writing reverse that w a v run and a new file has been created here on my directory.
If I click that play.
If you have a good year, then you'll be able to distinguish the difference, you see the original one.
Yeah, so they are different right now.
Let's talk for a while and see where did I get these methods and that methods?
Well, for a complete list of methods, you can apply to this.
All these segments object instance, you can do print the original run.
And so these are the methods.
So of course, we cannot go through all of them, but we're going to go through the most important ones
that you will be using.
So reverse we tried reverse.
If you go to our, you see these are in alphabetical order, you see reverse here and we also use export.
This one in here.
There are some things, though, which are not methods.
For example, if you want to extract only the first two seconds of the original audio file, the way
to do that is so let me comment that out by using least slicing syntax.
So let's say first to another variable, which will hold the two seconds all your object first to its
original from the second zero two.
You don't write two, but you write 2000 because this expects milliseconds.
You can also omits the zero.
That's not necessary.
I prefer to keep it.
It makes the code more readable and first to that exports to save all the objects to a file on disk.
Let's say first to that way file run.
And this is a file generated.
You see, it's two seconds long.
The original one was three seconds.
So.
Right now, if you want to see the length of and all the objects you can use, the Python Lend function
so original you run and you'll see it's something like three thousand five hundred sixty seven milliseconds.
So which means it's around 3.5, six, seven seconds here on Ripple, it shows.
S and No.
S an integer, so three seconds, but that's all we're Apple shows.
It's on the audio player to merge two audio files.
You can do this.
Merged equals to original plus.
Reversed, so we are merging that to that.
In other words, we are a pending reversed two original so original will be the first reverse will come
after that.
Let's export it to a file on disk and to listen to it.
It's a merged.
You see, it's seven seconds now because each of those audio files were 3.5 seconds each.
Right, sounds good.
You could also add an empty a silence between these two.
To do that, you could do.
I'll just segment that's silent.
Plus that silent for, let's say, a thousand milliseconds, so one second, let's override the existing
file, so run.
And listen to merge that wave.
So you see, it's eight seconds now.
One second silence, then starts again.
One more time.
Right.
So that is how you keep adding all your files, appending audio files to other audio files.
You can also use a multiplication operator.
So let's say you want two original tracks before.
So one after another and then a silence and then the reverse all do.
So run that.
No, it's going to be something like 11 seconds.
Yeah, it's 11 seconds.
I'm not a music expert, but this is sounding good to me so far.
And lastly, I would like to show you how to increase the volume of your audio.
Let's say we want the reversed port to be 15 more decibels.
To do that, what we can do is, we can say, reversed equals to reverse.
So the original plus 15 as intuitive as that, so now reversed is has a higher volume.
And then we add reverse here.
So reverse at this point will have a higher volume.
Therefore, we ready to execute this and listen to the merged file.
Yeah, so I think you were able to listen to tell that the volume of the lost part was higher.
And that is the complete code.
Let's have some more fun with music of the falls in the next video.
Thank you.