tsm-net / tsmnet /utils.py
ernestchu
update
b6ef12a
raw
history blame contribute delete
444 Bytes
import scipy.io.wavfile
def save_sample(file_path, sampling_rate, audio):
"""Helper function to save sample
Args:
file_path (str or pathlib.Path): save file path
sampling_rate (int): sampling rate of audio (usually 22050)
audio (torch.FloatTensor): torch array containing audio in [-1, 1]
"""
audio = (audio.numpy() * 32768).astype("int16")
scipy.io.wavfile.write(file_path, sampling_rate, audio)