Return value of librosa.effect.Split is strange

北慕城南 提交于 2020-01-14 19:08:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!