AttributeError:模块“librosa.feature”没有属性“short\u time\u energy”

2024-10-03 15:31:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用librosa从音频中提取短时能量,但我得到了

AttributeError: module 'librosa.feature' has no attribute 'short_time_energy'.

我需要一个解决这个问题的办法。 我的代码:

fn_list_i = [
    feature.short_time_energy
]
    
def calculateSTE(audio_signal, window_type, frame_length, hop_size):
    signal_new = []                           # container for signal square
    win = Windowing(type = window_type)       # instantiate window function
    
    # compute signal square by frame
    for frame in FrameGenerator(audio_signal, frameSize=frame_length, hopSize=hop_size, startFromZero=True):
        frame_new = frame**2
        signal_new.append(frame_new)
    
    # output the convolution of window and signal square
    return np.convolve(signal_new, win)

Tags: newsizesignaltimetypewindowframeaudio
1条回答
网友
1楼 · 发布于 2024-10-03 15:31:26

那是因为librosa没有这样的函数。您可能希望将其替换为例如RMS,它计算每个帧的均方根(RMS)值-本质上是能量

fn_list_i = [
    feature.rms
]

相关问题 更多 >