pydub (Part 2)
00:00
Now to the last bit of content for the course. After this video, you should feel comfortable using a variety of libraries to play, record, convert, and save audio using Python. In this video, we’re going to finish up by talking about using pydub for file conversions. Like soundfile, pydub is compatible with a number of different audio formats.
00:22
In fact, it supports any file format that ffmpeg supports. To show this, let’s make an MP3 out of one of the WAV files. Inside the editor, go from pydub import AudioSegment, and then create a sound.
00:39
This will just be an AudioSegment, and we’ll grab a WAV file, so .from_wav(), and pass in 'hello.wav'. To convert this to an MP3, you can just take that sound, and now export it!
00:55
And let’s just say 'new_hello.mp3',
01:02
and say the format is going to be 'mp3'.
01:06
You can see that this has a similar syntax to soundfile, where you read in the file to get the data, and then you export it to the new file type. All right, let’s try this out.
01:22
And look at that! new_hello.mp3 is there. So, that’s not too bad. Between soundfile and pydub, just about all of your conversion needs should be met.
01:33 Let’s take a couple minutes in the next video to recap what you’ve learned in an overview of each of these different libraries.
Become a Member to join the conversation.
