Skip to content

Instantly share code, notes, and snippets.

@toannhu
Created February 28, 2018 14:25
Show Gist options
  • Save toannhu/7ddcc152654e4ea2cb7f598e6235d813 to your computer and use it in GitHub Desktop.
Save toannhu/7ddcc152654e4ea2cb7f598e6235d813 to your computer and use it in GitHub Desktop.
from pydub import AudioSegment
from pydub import silence
from tqdm import tqdm
import os
def read_wav_info(wavfile):
print(sound.DEFAULT_CODECS)
print(sound.channels)
print(sound.converter)
print(sound.frame_rate)
print(sound.duration_seconds)
if not os.path.exists("./output/"):
os.makedirs("./output/")
for filename in tqdm(os.listdir(os.getcwd())):
if filename.lower().endswith("wav"):
sound = AudioSegment.from_wav(filename)
sound = sound.set_frame_rate(16000).set_channels(1)
sound.export("./output/" + filename, format="wav")
# sound = AudioSegment.from_wav("./output/1.wav")
# read_wav_info(sound)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment