def feature_gamma(audioname): def princarg(p): return ((p + np.pi) % -2 * np.pi) + np.pi audiopath = get_audiopath(audioname, INST) audiopath = get_audiopath(audioname, INST) y, _ = librosa.load(path=audiopath, **AUDIO) X_c = librosa.core.stft(y=y, **STFT).T X_m = np.abs(X_c) X_p = np.angle(X_c) X_up = np.unwrap(X_p) X_gamma = np.abs(X_m) for t in range(2, X_gamma.shape[1]): phi_target = princarg(2 * X_up[:, t - 1] - X_up[:, t - 2]) r_target = np.abs(X_m[:, t - 1]) phi_current = np.angle(X_c[:, t]) r_current = np.abs(X_c[:, t]) X_gamma[:, t] = np.sqrt( r_target ** 2 + r_current ** 2 - 2 * r_target * r_current * np.cos(phi_target - phi_current) ) X = X_gamma Y = get_targets(name).T return X, Y
def feature_acd(audioname): audiopath = get_audiopath(audioname, INST) y, _ = librosa.load(path=audiopath, **AUDIO) X_c = librosa.core.stft(y=y, **STFT).T X_cd = deviation(X_c) X_acd = np.abs(X_cd) X = X_acd Y = get_targets(name).T return X, Y
def feature_m_md(audioname): # get audiopath from audioname audiopath = get_audiopath(audioname, INST) y, _ = librosa.load(path=audiopath, **AUDIO) X_c = librosa.core.stft(y=y, **STFT).T X_m = np.abs(X_c) X_md = deviation(X_m) X = np.hstack((X_m, X_md)) Y = get_targets(name).T return X, Y
def feature_m(audioname): # get audiopath from audioname audiopath = get_audiopath(audioname, INST) y, _ = librosa.load(path=audiopath, **AUDIO) X_c = librosa.core.stft(y=y, **STFT).T # abs X_m = np.abs(X_c) X = X_m Y = get_targets(name).T return X, Y