Spaces:
Sleeping
Sleeping
import librosa | |
import numpy as np | |
from torch import Tensor | |
def pad(x, max_len=64600): | |
x_len = x.shape[0] | |
if x_len >= max_len: | |
return x[:max_len] | |
# need to pad | |
num_repeats = int(max_len / x_len)+1 | |
padded_x = np.tile(x, (1, num_repeats))[:, :max_len][0] | |
return padded_x | |
def process_ssl_assist_input(filepath): | |
X, fs = librosa.load(filepath, sr=16000) | |
X_pad = pad(X) | |
x_inp = Tensor(X_pad) | |
x_inp = x_inp.unsqueeze(0) | |
return x_inp | |
def process_assist_input(filepath): | |
return process_ssl_assist_input(filepath) |