Last active
April 16, 2023 21:51
-
-
Save tikhonova/2bfdede483b2aed68c9968754102bbe9 to your computer and use it in GitHub Desktop.
This file contains 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
def convert_audio_to_wav(filename: str, filepath: str, dest_path: str) -> None: | |
filepath = os.path.join(filepath, filename) | |
dest_filepath = os.path.join(dest_path, f"{filename[:-4]}.wav") | |
given_audio = AudioSegment.from_file(filepath, format="mp3") # replace with mp4 or avi | |
given_audio.export(dest_filepath, format="wav") | |
# create a list of input arguments for the function | |
inputs = [(filename, filepath, dest_path) for filename in os.listdir(filepath) if filename not in os.listdir(dest_path)] | |
# create a Process pool with 16 worker processes | |
if __name__ == '__main__': | |
freeze_support() | |
p = multiprocessing.Pool(16) | |
p.starmap(convert_audio_to_wav, inputs) | |
# via https://github.com/tikhonova/what_would_alan_watts_say/blob/master/speech_synthesis/0_audio_convert_to_wav.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment