File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -76,11 +76,11 @@ def _build_mel_basis():
7676
7777
7878def _amp_to_db (x ):
79- return 20 * np .log10 (np . maximum ( 1e-5 , x + 0.01 ) )
79+ return 20 * np .log10 (x + 0.01 )
8080
8181
8282def _db_to_amp (x ):
83- return np .power (10.0 , x * 0.05 )
83+ return np .maximum ( np . power (10.0 , x * 0.05 ) - 0.01 , 0.0 )
8484
8585
8686def _normalize (S ):
Original file line number Diff line number Diff line change 1+ # coding: utf-8
2+ from __future__ import with_statement , print_function , absolute_import
3+
4+ import sys
5+ from os .path import dirname , join
6+ sys .path .insert (0 , join (dirname (__file__ ), ".." ))
7+
8+ import numpy as np
9+ from nose .plugins .attrib import attr
10+
11+ import logging
12+ logging .getLogger ('tensorflow' ).disabled = True
13+
14+
15+ @attr ("local_only" )
16+ def test_amp_to_db ():
17+ import audio
18+ x = np .random .rand (10 )
19+ x_hat = audio ._db_to_amp (audio ._amp_to_db (x ))
20+ assert np .allclose (x , x_hat )
You can’t perform that action at this time.
0 commit comments