问题
As titled, the result of this function is not logical and I don't understand what the function is doing.
For example, here is some reproducible code:
#load sample audio
filename = librosa.util.example_audio_file()
audio, sr = librosa.load(filename)
#get intervals which are non-silent
inter_20 = librosa.effects.split(audio, top_db=20) #audio above 20dB
inter_5 = librosa.effects.split(audio, top_db=5) #audio above 5dB
#create audio
above_20 = np.zeros(audio.shape)
above_5 = np.zeros(audio.shape)
for i in inter_20:
start,end = i
above_20[start:end]=audio[start:end]
for j in inter_5:
start,end = j
above_5[start:end]=audio[start:end]
#plot them out:
plt.figure(figsize=[15,3]) #figure 1
plt.plot(audio)
plt.plot(above_5,color='red')
plt.title('Audio above 5 dB')
plt.figure(figsize=[15,3]) #figure 2
plt.plot(audio)
plt.plot(above_20,color='red')
plt.title('Audio above 20 dB')
you can see from here: for figure 1, which is audio above 5dB:
for figure 2, which is audio above 20dB:
How can it be that audio above 20dB is more than audio above 5dB? To me this doesn't make sense.
回答1:
From the documentation at: https://librosa.github.io/librosa/generated/librosa.effects.split.html
top_db:number > 0
The threshold (in decibels) **below** reference to consider as silence
I think top_db:20 means everything below (TOP - 20dB) instead of just 20dB is considered silence.
And there will be more above TOP - 20dB than TOP - 5dB. It also could explain your pictures.
来源:https://stackoverflow.com/questions/58951102/return-value-of-librosa-effect-split-is-strange