to_decibel

ketos.audio.utils.misc.to_decibel(x)[source]
Convert any data array, y, typically a spectrogram, from linear scale

to decibel scale by applying the operation 20\log_{10}(y).

Args:
xnumpy array

Input array

Returns:
ynumpy array

Converted array

Example:
>>> import numpy as np
>>> from ketos.audio.utils.misc import to_decibel 
>>> img = np.array([[10., 20.],[30., 40.]])
>>> img_db = to_decibel(img)
>>> img_db = np.around(img_db, decimals=2) # only keep up to two decimals
>>> print(img_db)
[[20.0 26.02]
 [29.54 32.04]]