Created
March 9, 2020 06:37
-
-
Save yuyyuyu/9011d231c39ca8926c4bb6ad5e3d5c5a 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 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") | |
noise=np.random.randn(len(data)) | |
factor=0.01 | |
noised_data=data+noise*factor | |
librosa.output.write_wav('noised_haruhi.wav', noised_data,sr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment