np import numpy as np import scipy as scp import matplotlib.pyplot as plt pred = np.load("result_both/FALSE/out_21220302_105301UTC_V00OS11.WAV_pred.npy") pos = np.load("result_both/FALSE/out_21220302_105301UTC_V00OS11.WAV_pos_sequence.npy") pos pred > 0.5 pred[:,1] > 0.5 positif = pred[:,1] > 0.5 positif idx_pos = pred[:,1] > 0.5 pos = np.load("result_both/FALSE/out_21220302_105301UTC_V00OS11.WAV_pos_sequence.npy") pos[idx_pos] anot_list = list() for idx_f in pos[idx_pos]: break idx_f import soundfile as sf sig, sr = sf.read("/nfs/NAS6/SABIOD/SITE/CARIMAM/DATA/LOT2/BON_20210211-131700UTC_20320321/21220302_105301UTC_V00OS11.WAV") sig[idx_f*sr: (idx_f+0.128)*sr] sig[int(idx_f*sr): int((idx_f+0.128)*sr)] plt.plot(sig[int(idx_f*sr): int((idx_f+0.128)*sr)]);plt.show() tmp = sig[int(idx_f*sr): int((idx_f+0.128)*sr)] self.hp_sos = sg.butter(3, 2500, 'hp', output='sos', fs=_FS) self.hp_sos = scp.signal.butter(3, 2500, 'hp', output='sos', fs=_FS) self.hp_sos = scp.signal.butter(3, 2500, 'hp', output='sos', fs=sr) hp_sos = scp.signal.butter(3, 2500, 'hp', output='sos', fs=sr) tmp = sg.sosfiltfilt(hp_sos, tmp) tmp = scp.signal.sosfiltfilt(hp_sos, tmp) plt.plot(tmp);plt.show() idx_max = np.argmax(np.abs(tmp)) plt.plot(tmp);plt.plot(idx_max, tmp[idx_max], "*");plt.show() idx_max idx_max/sr idx_f + (idx_max/sr) anot_list = list() for idx_f in pos[idx_pos]: tmp = sig[int(idx_f*sr): int((idx_f+0.128)*sr)] tmp = scp.signal.sosfiltfilt(hp_sos, tmp) idx_max = np.argmax(np.abs(tmp)) anot_list.append(idx_f + (idx_max/sr)) anot_list idx_pos.sum() plt.plot(sig); plt.plot(anot_list, sig[anot_list]);plt.show() plt.plot(sig); plt.plot(anot_list, sig[int(anot_list*sr)]);plt.show() plt.plot(sig); plt.plot(anot_list, sig[int(np.array(anot_list)*sr)]);plt.show() plt.plot(sig); plt.plot(anot_list, sig[(anot_list*sr).astype(int)]);plt.show() plt.plot(sig); plt.plot(anot_list, sig[(np.array(anot_list)*sr).astype(int)]);plt.show() plt.plot(sig); plt.plot(anot_list, sig[(np.array(anot_list)*sr).astype(int)], *);plt.show() plt.plot(sig); plt.plot(anot_list, sig[(np.array(anot_list)*sr).astype(int)], "*");plt.show() plt.plot(sig); plt.plot(np.array(anot_list*sr).astype(), sig[(np.array(anot_list)*sr).astype(int)], "*");plt.show() plt.plot(sig); plt.plot((np.array(anot_list)*sr).astype(), sig[(np.array(anot_list)*sr).astype(int)], "*");plt.show() plt.plot(sig); plt.plot((np.array(anot_list)*sr).astype(int), sig[(np.array(anot_list)*sr).astype(int)], "*");plt.show() anot_list plt.plot(sig); plt.plot((np.array(anot_list)*sr).astype(int), sig[(np.array(anot_list)*sr).astype(int)], "*");plt.show() %history -f MANIP_ANOT.TXT