最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to work with the librosa.amplitude_to_db function - Stack Overflow

programmeradmin0浏览0评论

I am working with liberosa and I need to get the estimate dB out of a few audio files. I thought I could easly use the librosa.amplitude_to_db function but I have a problem.

I don't knowe what I did wrong. What do I need to do to solve this problem? I use the librosa.amplitude_to_db function and I am geting strange Spectrograms. like this image and when I make a Spectrogramme of the amplitude of the same audio recording I get this image. this is the code I use with the function.

# importing library
import librosa
import numpy as np
import matplotlib.pyplot as plt

# path to files 
pathAudio = "Path to the audio files"
files = librosa.util.find_files(pathAudio)
files = np.asarray(files)

# load al audio recordings
for i in files:
    data = librosa.load(i, sr=None, mono=True)
    data = data[0]
    
    #trim audio recordings(remove all zero)
    data = librosa.effects.trim(data)
    data = data[0]
    
    # convert all ampletudie to dB
    db = librosa.amplitude_to_db(data)

    data = data[0]
    
    # plot Spectrogramme
    fig, ax = plt.subplots()

    librosa.display.waveshow(db)
    ax.set_title("audio_name")
    ax.set_ylabel("dB")
    ax.set_xlabel("time")

plt.show()

I don't knowe how to get a dB which can be use or is this a useful dB?

thank you in advance.

发布评论

评论列表(0)

  1. 暂无评论