carankt's picture
Add files using upload-large-folder tool
bb96854 verified
Raw
History Blame Contribute Delete
497 Bytes
import librosa
from scipy.io.wavfile import write as wavwrite
def read_audio_file(file_path, sr):
"""
Reads audio file to system memory.
"""
return librosa.core.load(file_path, mono=False, sr=sr)[0]
def write_audio_file(file_path, data, sr):
"""
Writes audio file to system memory.
@param file_path: Path of the file to write to
@param data: Audio signal to write (n_channels x n_samples)
@param sr: Sampling rate
"""
wavwrite(file_path, sr, data.T)