The following notebook demonstrates frequency spectra of all filters wrapped in a MelFilterBank
.
We start off with our usual imports:
In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
The following hack won't be necessary after a proper release is made.
In [2]:
import sys
sys.path.append('..')
from dspy.filters import MelFilterBank
Let's set sample frequency (in Hz) and the size of data frames with which the filter bank would work.
In [3]:
sample_frequency = 44100
size = 4096
filter_bank = MelFilterBank(sample_frequency, size)
We can inspect frequency bands for each filter in linear scale:
In [4]:
for i, mel_filter in enumerate(filter_bank.filters):
print '%2d: %7.2f - %7.2f - %7.2f' % (i, mel_filter.min_freq, mel_filter.center_freq, mel_filter.max_freq)
Let's see that on a plot.
In [5]:
frequencies = np.linspace(0, sample_frequency, size, endpoint=False)
for mel_filter in filter_bank.filters:
plt.plot(frequencies, mel_filter.spectrum)
plt.xlim([0, filter_bank.filters[-1].max_freq])
plt.xlabel('Frequency (linear scale)')
plt.ylabel('Filter spectrum magnitude')
plt.title('Mel filter spectra')
plt.show()
In [ ]:
In [ ]: