我遇到两个错误,“算法”对象没有属性“音频”,名称“ logNorm”未定义
我也许忘记加载某些库了吗?
我的代码在Google collab上。
有问题的代码是:
从matplotlib.colors导入LogNorm 进口精华素
mfccs = [] melbands = [] melbands_log = []
对于FrameGenerator中的帧(音频,frameSize = 1024,hopSize = 512,startFromZero = True): mfcc_bands,mfcc_coeffs = mfcc(频谱(w(帧))) mfccs.append(mfcc_coeffs) melbands.append(mfcc_bands) melbands_log.append(logNorm(mfcc_bands)) mfccs = essentia.array(mfccs).T melbands = essentia.array(melbands.T) melbands_log = essentia.array(melbands_log).T
imshow(melbands [:,:],Aspect ='auto',origin ='lower',插值='none') plt.title(“帧中的梅尔带光谱能量”) show()
imshow(melbands_log [:,:],Aspect ='auto',origin ='lower',插值='none') plt.title(“对数归一化的梅尔带光谱能量,以帧为单位”) show()
imshow(mfccs [1:,:],Aspect ='auto',origin ='lower',插值='none') plt.title(“框架中的MFCC”) show()
NameError跟踪(最近一次通话) 在()中 10个mfccs.append(mfcc_coeffs) 11个melbands.append(mfcc_bands) ---> 12个melbands_log.append(logNorm(mfcc_bands)) 13 14#转置以使其形状更好
NameError:名称'logNorm'未定义
并且:
从pylab导入* 来自essentia.streaming进口* loader = ess.MonoLoader(文件名=文件) framecutter = ess.FrameCutter(frameSize = 4096,hopSize = 2048) windowing = ess.Windowing(type ='blackmanharris62') 频谱= ess.Spectrum() Spectrumpeaks = ess.SpectralPeaks(orderBy ='magnitude', 幅度阈值= 0.00001, minFrequency = 20, maxFrequency = 3500, maxPeaks = 60)
hpcp = ess.HPCP() hpcp_key = ess.HPCP(size = 36,#我们需要更高分辨率的密钥估计 referenceFrequency = 440,#假设调谐频率为44100。 bandPreset = False, minFrequency = 20, maxFrequency = 3500, weightType ='余弦', nonLinear = False, windowSize = 1。)
key = ess.Key(profileType ='edma',#将配置文件用于电子音乐 numHarmonics = 4, pcpSize = 36, 斜率= 0.6, usePolyphony = True, useThreeChords = True) 池= essentia.Pool() loader.audio >> framecutter.signal framecutter.frame >> windowing.frame >> Spectrum.frame 光谱。光谱>>光谱峰。光谱 Spectrumpeaks.magnitudes >> hpcp.magnitudes Spectrumpeaks.frequencies >> hpcp.frequencies Spectrumpeaks.magnitudes >> hpcp_key.magnitudes Spectrumpeaks.frequencies >> hpcp_key.frequencies hpcp_key.hpcp >> key.pcp hpcp.hpcp >>(池,'tonal.hpcp') key.key >>(池,'tonal.key_key') key.scale >>(池,'tonal.key_scale') key.strength >>(池,'tonal.key_strength') essentia.run(loader)
imshow(pool ['tonal.hpcp']。T,Aspect ='auto',origin ='lower',插值='none') plt.title(“帧中的HPCP(第0个HPCP系数对应于A)”) show()
print(“估计的键和标度:”,pool ['tonal.key_key'] +“” + pool ['tonal.key_scale'])
AttributeError跟踪(最近一次通话) 在()中 37 38#连接流算法 ---> 39 loader.audio >> framecutter.signal 40帧切割器框架>>窗框架>>光谱框架 41光谱。光谱>>光谱峰值。光谱
AttributeError:“算法”对象没有属性“音频”
它工作较早,我认为是因为我以不同的顺序运行笔记本。现在不知怎么不起作用了...有什么想法吗?基本上是教程代码...