当前位置:网站首页>认识提取与显示梅尔谱图的小实验(观察不同y_axis和x_axis的区别)
认识提取与显示梅尔谱图的小实验(观察不同y_axis和x_axis的区别)
2022-07-05 23:56:00 【Begonia_cat】
导入librosa
import librosa
读取音频
y, sr = librosa.load("C:/Users/24061/Desktop/MER数据集/DEAM/DEAM_audio/MEMD_audio_wav/2.wav")
y
array([0. , 0. , 0. , ..., 0.4163208 , 0.43338013,
0.40551758], dtype=float32)
sr
22050
提取梅尔谱图
mel_spectrogram = librosa.feature.melspectrogram(y=y, sr=sr, n_fft=2048, hop_length=1024)
mel_spectrogram # type: numpy.ndarray
array([[0.00000000e+00, 1.25761675e-02, 2.62945890e+00, ...,
4.08293676e+00, 7.79196739e+00, 5.92219353e+00],
[0.00000000e+00, 1.00206733e-01, 1.33076525e+00, ...,
6.49990678e-01, 1.44000304e+00, 1.67580545e+00],
[0.00000000e+00, 4.64823037e-01, 1.54586525e+01, ...,
3.54503012e+00, 2.53890848e+00, 9.59981441e+00],
...,
[0.00000000e+00, 6.95451519e-09, 3.43443826e-05, ...,
6.05733460e-03, 1.72329806e-02, 7.06060929e-03],
[0.00000000e+00, 7.65795605e-09, 7.63881962e-06, ...,
1.81941327e-03, 3.55470460e-03, 4.70093498e-03],
[0.00000000e+00, 4.74458783e-09, 5.26388646e-07, ...,
1.27859021e-04, 7.03962069e-05, 1.91266462e-03]], dtype=float32)
mel_spectrogram.shape
(128, 971)
显示梅尔谱图
1、没有转化为对数谱时
- 以梅尔标度显示频率
y_axis='mel'
import librosa.display
librosa.display.specshow(mel_spectrogram, y_axis='mel', x_axis='time')
<matplotlib.collections.QuadMesh at 0x23d902a60b8>
- 以对数标度显示频率
y_axis='log'
librosa.display.specshow(mel_spectrogram, y_axis='log', x_axis='time')
<matplotlib.collections.QuadMesh at 0x23d92827e80>
2、将幅度转化为对数
mel_spectrogram_db = librosa.amplitude_to_db(mel_spectrogram)
mel_spectrogram_db
array([[-19.654686 , -19.654686 , 8.397327 , ..., 12.219453 ,
17.832943 , 15.449652 ],
[-19.654686 , -19.654686 , 2.482029 , ..., -3.7418575,
3.167268 , 4.484472 ],
[-19.654686 , -6.6542473, 23.783434 , ..., 10.992398 ,
8.092941 , 19.645256 ],
...,
[-19.654686 , -19.654686 , -19.654686 , ..., -19.654686 ,
-19.654686 , -19.654686 ],
[-19.654686 , -19.654686 , -19.654686 , ..., -19.654686 ,
-19.654686 , -19.654686 ],
[-19.654686 , -19.654686 , -19.654686 , ..., -19.654686 ,
-19.654686 , -19.654686 ]], dtype=float32)
mel_spectrogram_db.shape
(128, 971)
- 以梅尔标度显示频率
y_axis="mel"
librosa.display.specshow(mel_spectrogram_db, y_axis="mel",x_axis="time" )
<matplotlib.collections.QuadMesh at 0x23d9194ce10>
- 以对数标度显示频率
y_axis="log"
librosa.display.specshow(mel_spectrogram_db, y_axis="log",x_axis="time" )
<matplotlib.collections.QuadMesh at 0x23d925c7cc0>
以Hz显示频率y_axis="hz"
librosa.display.specshow(mel_spectrogram_db, y_axis="hz",x_axis="time" )
<matplotlib.collections.QuadMesh at 0x23d92c2f5f8>
- 以对数谱显示频率
y_axis="log"
,时间单位为秒x_axis="s"
librosa.display.specshow(mel_spectrogram_db, y_axis="log",x_axis="s" )
<matplotlib.collections.QuadMesh at 0x23d9348a550>
- 以对数谱显示频率
y_axis="log"
,时间单位为毫秒x_axis="ms"
librosa.display.specshow(mel_spectrogram_db, y_axis="log",x_axis="ms" )
<matplotlib.collections.QuadMesh at 0x23d93ea76a0>
节奏(待续),还没搞太明白
librosa.feature.fourier_tempogram(y, sr)
C:\Users\24061\anaconda3\envs\tensorflow\lib\site-packages\ipykernel_launcher.py:1: FutureWarning: Pass y=[0. 0. 0. ... 0.4163208 0.43338013 0.40551758], sr=22050 as keyword args. From version 0.10 passing these as positional arguments will result in an error
"""Entry point for launching an IPython kernel.
array([[ 1.41953934e+02+0.0000000e+00j, 1.43232498e+02+0.0000000e+00j,
1.44507858e+02+0.0000000e+00j, ...,
1.20833031e+02+0.0000000e+00j, 1.19599785e+02+0.0000000e+00j,
1.18365807e+02+0.0000000e+00j],
[-8.12093430e+01+7.8693253e+01j, -8.25004044e+01+7.8347717e+01j,
-8.37830200e+01+7.7980965e+01j, ...,
-6.11498871e+01-7.6005348e+01j, -5.98955841e+01-7.6018913e+01j,
-5.86419067e+01-7.6011627e+01j],
[ 2.08344612e+01-5.4645943e+01j, 2.22085571e+01-5.3934937e+01j,
2.35550823e+01-5.3178368e+01j, ...,
1.26519930e+00+5.0331814e+01j, 4.82287928e-02+5.0350494e+01j,
-1.16933417e+00+5.0330265e+01j],
...,
[-3.68897580e-02-7.4101496e-01j, 9.78471190e-02+7.0739186e-01j,
-1.57261893e-01-6.6958255e-01j, ...,
-4.85646218e-01+1.2208136e-01j, 4.81895536e-01-1.4795184e-01j,
-4.76868808e-01+1.7341925e-01j],
[-1.62224078e+00-6.7166932e-02j, 1.64763165e+00+3.6856860e-02j,
-1.67323339e+00-5.3153611e-03j, ...,
6.40185595e-01-6.1752874e-01j, -6.37307167e-01+6.1541033e-01j,
6.34444416e-01-6.1347997e-01j],
[ 1.42917812e+00+0.0000000e+00j, -1.40549254e+00+0.0000000e+00j,
1.38058436e+00+0.0000000e+00j, ...,
-1.41562808e+00+0.0000000e+00j, 1.39833307e+00+0.0000000e+00j,
-1.38108861e+00+0.0000000e+00j]], dtype=complex64)
librosa.display.specshow(librosa.amplitude_to_db(librosa.feature.fourier_tempogram(y, sr)))
C:\Users\24061\anaconda3\envs\tensorflow\lib\site-packages\ipykernel_launcher.py:1: FutureWarning: Pass y=[0. 0. 0. ... 0.4163208 0.43338013 0.40551758], sr=22050 as keyword args. From version 0.10 passing these as positional arguments will result in an error
"""Entry point for launching an IPython kernel.
C:\Users\24061\anaconda3\envs\tensorflow\lib\site-packages\librosa\util\decorators.py:88: UserWarning: amplitude_to_db was called on complex input so phase information will be discarded. To suppress this warning, call amplitude_to_db(np.abs(S)) instead.
return f(*args, **kwargs)
<matplotlib.collections.QuadMesh at 0x23d9325f860>
边栏推荐
- [Luogu cf487e] tours (square tree) (tree chain dissection) (line segment tree)
- Cloudcompare & PCL point cloud randomly adds noise
- Asynchronous task Whenall timeout - Async task WhenAll with timeout
- [SQL] SQL expansion languages of mainstream databases (T-SQL, pl/sql, pl/pgsql)
- SpreadJS 15.1 CN 与 SpreadJS 15.1 EN
- 【二叉搜索树】增删改查功能代码实现
- 【luogu CF487E】Tourists(圆方树)(树链剖分)(线段树)
- Zhongjun group launched electronic contracts to accelerate the digital development of real estate enterprises
- Spire. PDF for NET 8.7.2
- el-cascader的使用以及报错解决
猜你喜欢
China Jinmao online electronic signature, accelerating the digitization of real estate business
Biased sample variance, unbiased sample variance
4 points tell you the advantages of the combination of real-time chat and chat robots
激光slam学习记录
C# 反射与Type
Tips for using pads router
What if the C disk is not enough? Let's see how I can clean up 25g of temp disk space after I haven't redone the system for 4 years?
Use mapper: --- tkmapper
After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!
保研笔记四 软件工程与计算卷二(8-12章)
随机推荐
同事悄悄告诉我,飞书通知还能这样玩
第16章 OAuth2AuthorizationRequestRedirectWebFilter源码解析
云呐|公司固定资产管理系统有哪些?
Learn PWN from CTF wiki - ret2libc1
QT a simple word document editor
云呐|固定资产管理系统功能包括哪些?
JVM details
18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)
QT QPushButton details
如何提升口才
【二叉搜索树】增删改查功能代码实现
如何让同步/刷新的图标(el-icon-refresh)旋转起来
行列式学习笔记(一)
[online chat] the original wechat applet can also reply to Facebook homepage messages!
Fiddler Everywhere 3.2.1 Crack
In C#, why can't I modify the member of a value type instance in a foreach loop?
Bao Yan notebook IV software engineering and calculation volume II (Chapter 8-12)
Add noise randomly to open3d point cloud
STM32__06—单通道ADC
Make a short video clip number of we media film and television. Where can I download the material?