-
Notifications
You must be signed in to change notification settings - Fork 15
/
BOB.py
executable file
·25 lines (22 loc) · 854 Bytes
/
BOB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from utils import cached_func, diff_feature
import bob
import bob.ap
import numpy
@cached_func
def get_bob_extractor(fs, win_length_ms=32, win_shift_ms=16,
n_filters=55, n_ceps=19, f_min=0., f_max=6000,
delta_win=2, pre_emphasis_coef=0.95, dct_norm=True,
mel_scale=True):
ret = bob.ap.Ceps(fs, win_length_ms, win_shift_ms, n_filters, n_ceps, f_min,
f_max, delta_win, pre_emphasis_coef, mel_scale, dct_norm)
return ret
def extract(fs, signal=None, diff=False, **kwargs):
"""accept two argument, or one as a tuple"""
if signal is None:
assert type(fs) == tuple
fs, signal = fs[0], fs[1]
signal = numpy.cast['float'](signal)
ret = get_bob_extractor(fs, **kwargs)(signal)
if diff:
return diff_feature(ret)
return ret