Created
March 9, 2020 06:40
-
-
Save yuyyuyu/41b7f2de1b9547feeadf386de682c3b3 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
import numpy as np | |
import random | |
import itertools | |
import librosa | |
import IPython.display as ipd | |
import matplotlib.pyplot as plt | |
def stretch(data,rate=1): | |
input_length = 440000 | |
data=librosa.effects.time_stretch(data,rate) | |
return data | |
def load_audio_file(file_path): | |
input_length = 440000 | |
data = librosa.core.load(file_path,sr=22050)[0] #, sr=16000 | |
if len(data)>input_length: | |
data = data[:input_length] | |
else: | |
data = np.pad(data, (0, max(0, input_length - len(data))), "constant") | |
return data | |
sr=22050 | |
data = load_audio_file("haruhi.wav") | |
data_stretch=stretch(data,0.8) | |
librosa.output.write_wav('stretch0.8_haruhi.wav', data_stretch,sr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment