I am having trouble with converting the array of samples to decibels. Here's the code I've tried.
from pydub import AudioSegment
audio=AudioSegment.from_mp3('am_voice.mp3')
samples=audio.get_array_of_samples()
import math
def convert_to_decibel(arr):
if arr!=0:
return 10 * math.log10(abs(arr))
else:
return -60
data=[convert_to_decibel(i) for i in samples]
This returns all positive data. Whereas, the decibel value should be always negative. Here's the data I want to create :
percentile=np.percentile(data,[25,50,75])
print(f"1st Quartile : {percentile[0]}")
print(f"2nd Quartile : {percentile[1]}")
print(f"3rd Quartile : {percentile[2]}")
print(f"Mean : {np.mean(data)}")
print(f"Median : {np.median(data)}")
print(f"Standard Deviation : {np.std(data)}")
print(f"Variance : {np.var(data)}")
Any help would be appreciated.
PS: I have tried librosa and other libraries too.
