Last active
April 13, 2020 17:48
-
-
Save openroomxyz/72f6313e4cf3874e5559866e00235eb3 to your computer and use it in GitHub Desktop.
Python : How can i convert all files in folder from ogg to mp3?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from pydub import AudioSegment | |
| def get_list_of_files_only_in_folder(folder_path): | |
| return [f for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))] | |
| def convert_from_ogg_to_mp3(path_file_input, path_file_output): | |
| ogg_version = AudioSegment.from_ogg(path_file_input) | |
| ogg_version.export(path_file_output, format="mp3") | |
| path_in = "C://Users//X//Desktop//X//A" | |
| path_out = "C://Users//X//Desktop//X//B" | |
| files_path_list = get_list_of_files_only_in_folder(path_in) | |
| for file_name in files_path_list: | |
| convert_from_ogg_to_mp3(path_in+"//"+file_name, ("".join((path_out+"//"+file_name).split(".")[:-1])+".mp3")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment