如何在librosa spectompomm上显示更多频率
我正在尝试使用日志尺度绘制44.1 kHz音频谱图。但是天秤座仅显示 2^14 (16384)Hz,但这应该是 2^15 和 2^16 Hz之间的东西。我如何绘制全尺度光谱图?
import matplotlib.pyplot as plt
import librosa.display
import numpy as np
import pandas as pd
import librosa
y, sr1 = librosa.load('sample01.wav', duration=10,sr=44100)
S = np.abs(librosa.stft(y))
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
img = librosa.display.specshow(librosa.amplitude_to_db(S,ref=np.max), y_axis='log',sr=sr1, x_axis='time', ax=ax)
ax.set_title('Log')
fig.colorbar(img, ax=ax, format="%+2.0f dB")
plt.show()
I'm trying to plot 44.1 kHz audio spectrogram with log-scale. But librosa shows only 2^14 (16384) Hz, but it should be something between 2^15 and 2^16 Hz. How I can plot full-scale spectrogram?
import matplotlib.pyplot as plt
import librosa.display
import numpy as np
import pandas as pd
import librosa
y, sr1 = librosa.load('sample01.wav', duration=10,sr=44100)
S = np.abs(librosa.stft(y))
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
img = librosa.display.specshow(librosa.amplitude_to_db(S,ref=np.max), y_axis='log',sr=sr1, x_axis='time', ax=ax)
ax.set_title('Log')
fig.colorbar(img, ax=ax, format="%+2.0f dB")
plt.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
天秤座工作正常,显示频率高达FS/2。很难在日志刻度上看到。您可以使用Zoom-In到顶部,您会发现它达到了21.05kHz左右。
我修改了您的示例,下面添加了设置yticks,以证明这些频率在那里(OFC必须发出一些随机信号)
Librosa works correctly and shows frequencies up to fs/2. It is hard to see on log scale. You can either use zoom-in to top part and you will see that it gets to around 21.05kHz.
I modified your example, added below setting yticks, to prove those frequencies are there (and ofc had to make some random signal)