我想基于r_c_1数据帧中看到的值替换我的offset_frames数据帧中的值。因此,例如offset_frames将从(62,54,48,45,29,18)变为(1,9,15,18,34,45)。我将如何去做?
这是我的代码:
import librosa
import glob
import pandas as pd
import numpy as np
filenames = ((/hide/*wav'))
audiofile = filenames
for f in audiofile:
x, fs = librosa.load(f)
hop_length = 512
onset_frames = librosa.onset.onset_detect(x, sr=fs, hop_length=hop_length, backtrack=True)
onset_times = librosa.frames_to_time(onset_frames, sr=fs, hop_length=hop_length)
y=x[::-1]
hop_length = 512
offset_frames = librosa.onset.onset_detect(y, sr=fs, hop_length=hop_length, backtrack=True)
offset_times = librosa.frames_to_time(offset_frames, sr=fs, hop_length=hop_length)
c =librosa.util.frame(x)
c_1 = list(range(1, len(c[1,:])+1))
c_1_1= pd.DataFrame(c_1)
rc = c_1[::-1]
rc_1=pd.DataFrame(rc)
r_c = [c_1_1,rc_1]
r_c_1 = pd.concat(r_c,axis=1)