Created
February 28, 2018 14:25
-
-
Save toannhu/7ddcc152654e4ea2cb7f598e6235d813 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
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