gpt4 book ai didi

python - Librosa:过滤奈奎斯特以外的通带

转载 作者:行者123 更新时间:2023-12-02 22:15:01 25 4
gpt4 key购买 nike

Librosa Python 3.5在 8000Hhz 音频样本上出现错误:

extract feature error. Filter pass-band lies beyond Nyquist

之前遇到过有关 Nyquist 的其他错误,但通过手动设置 sr 和 fmin 得到修复,但似乎无法通过此错误。

stft = np.abs(librosa.stft(X))
mfccs = np.mean(librosa.feature.mfcc(y=X, sr=8000, n_mfcc=40, fmin=60).T,axis=0)
chroma = np.mean(librosa.feature.chroma_stft(S=stft, sr=8000).T,axis=0)
mel = np.mean(librosa.feature.melspectrogram(X, sr=8000, fmin=60).T,axis=0)
contrast = np.mean(librosa.feature.spectral_contrast(S=stft, sr=8000, fmin=60).T,axis=0)
tonnetz = np.mean(librosa.feature.tonnetz(y=librosa.effects.harmonic(X), sr=8000).T,axis=0)
return mfccs, chroma, mel, contrast, tonnetz

编辑:

tonnetz 功能似乎存在问题。每docs色度:

np.ndarray [shape=(n_chroma, t)] or None

Normalized energy for each chroma bin at each frame.

If None, a cqt chromagram is performed.

cqt 色度图需要额外的参数才能与 8000Hhz 音频一起使用,因此我需要手动设置色度。不幸的是,这超出了我的 Librosa/Audio 知识范围,有人为我提供了线索吗?

最佳答案

    stft = np.abs(librosa.stft(X))
mfccs = np.mean(librosa.feature.mfcc(y=X, sr=8000, n_mfcc=40, fmin=30).T,axis=0)
chroma = np.mean(librosa.feature.chroma_stft(S=stft, sr=8000).T,axis=0)
mel = np.mean(librosa.feature.melspectrogram(X, sr=8000, fmin=30).T,axis=0)
contrast = np.mean(librosa.feature.spectral_contrast(S=stft, sr=8000, fmin=30).T,axis=0)
tonnetz = np.mean(librosa.feature.tonnetz(y=librosa.effects.harmonic(X), sr=sample_rate, chroma=librosa.feature.chroma_cqt(y=X, sr=8000, fmin=30)).T,axis=0)
return mfccs, chroma, mel, contrast, tonnetz

关于python - Librosa:过滤奈奎斯特以外的通带,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56437543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com