Created
December 4, 2019 17:47
-
-
Save dansuh17/fa04843cbb4140d42c47ef44e15964e9 to your computer and use it in GitHub Desktop.
Revisions
-
dansuh17 revised this gist
Dec 4, 2019 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,5 +17,4 @@ dst_name = f'{TO_DIR}_{i}.wav' dst_path = os.path.join(ROOT, TO_DIR, dst_name) wavfile.write(dst_path, rate=SAMPLE_RATE, data=audio_data) -
dansuh17 created this gist
Dec 4, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import librosa import os from scipy.io import wavfile ROOT = '.' DIR = 'src' # source directory TO_DIR = 'dst' # destination directory SAMPLE_RATE = 16000 for i, fname in enumerate(os.listdir(os.path.join(ROOT, DIR))): base, ext = os.path.splitext(fname) fpath = os.path.join(ROOT, DIR, fname) audio_data, _ = librosa.load(fpath, sr=SAMPLE_RATE) # resample while loading # naming format: {dst_dir}_{index}.wav dst_name = f'{TO_DIR}_{i}.wav' dst_path = os.path.join(ROOT, TO_DIR, dst_name) wavfile.write(dst_path, rate=SAMPLE_RATE, data=audio_data)