Created
February 8, 2022 06:16
-
-
Save andirkh/536afdb2abbf66c1bbd0d48e3bcc8d4c to your computer and use it in GitHub Desktop.
Convert Stereo to Mono
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
import os | |
from pydub import AudioSegment | |
DIRECTORY = './your_directory' | |
LIST_DIR = os.listdir(DIRECTORY) | |
for filename in sorted(LIST_DIR): | |
if filename.endswith('.wav'): | |
sound = AudioSegment.from_wav(DIRECTORY + "/" + filename) | |
sound = sound.set_channels(1) | |
namesplit = filename.split('_') | |
newName = namesplit[0] + '_mono_' + namesplit[1] | |
sound.export(newName, format="wav") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment