首页 > 解决方案 > 如何在 Python 中执行 Matlab 函数“pspectrum”(可能使用 numpy)

问题描述

我想分析几秒钟的声音并直观地查看整个声音中使用的每个频率的功率。在 matlab 中,我可以使用函数 pspectrum 并得到一些看起来像

这个

有没有办法在 python 中使用 numpy 或类似的库来做到这一点?

标签: pythonmatlabnumpysignal-processing

解决方案


在 python 中执行频谱图有两种方法。首先,使用 scipy 库,其次使用 matplotlib 库。scipy 库是最常用的,因为整个 scipy 库都是用于信号处理的。此外,matplotlib 谱图函数比 scipy 具有更多的功能。

我会说使用 matpoltlib 函数,因为 matplotlib 库是专门用于可视化的。请找到两个库文档的链接。

为频谱安装 python 库:1.) scipy library = pip install scipy(文档 - https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.spectrogram.html

2.)matplotlib 库 = pip install matplotlib(文档- https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.specgram.html#matplotlib.axes.Axes.specgram

免费提出与此主题相关的更多问题。祝你好运!


推荐阅读