Skip to content

Instantly share code, notes, and snippets.

@andirkh
Created February 8, 2022 06:16
Show Gist options
  • Save andirkh/536afdb2abbf66c1bbd0d48e3bcc8d4c to your computer and use it in GitHub Desktop.
Save andirkh/536afdb2abbf66c1bbd0d48e3bcc8d4c to your computer and use it in GitHub Desktop.
Convert Stereo to Mono
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