Advertisement

使用librosa绘制音频图

阅读量:

librosa音频可视化应用

今日无意间了解到librosa库具备生成音频特征相关图形的功能,特此进行记录与归纳。

复制代码
    import librosa.display
    import numpy as np
    import matplotlib.pyplot as plt
    
    #	这里插入提取音频的路径
    y, sr = librosa.load(librosa.util.example_audio_file())
    
    # 使用stft频谱求Mel频谱
    D = np.abs(librosa.stft(y)) ** 2  # stft频谱
    S = librosa.feature.melspectrogram(S=D)  # 使用stft频谱求Mel频谱
    
    plt.figure(figsize=(10, 4))
    librosa.display.specshow(librosa.power_to_db(S, ref=np.max),
                         y_axis='mel', fmax=8000, x_axis='time')
    plt.colorbar(format='%+2.0f dB')
    plt.title('Mel spe

全部评论 (0)

还没有任何评论哟~