annotate gmm_baseline_experiments/external_libs/librosa/librosa-0.3.1/tests/testLibrosaUtil.py @ 5:b523456082ca
tip
Update path to dataset and reflect modified chunk naming convention.
author |
peterf |
date |
Mon, 01 Feb 2016 21:35:27 +0000 |
parents |
cb535b80218a |
children |
|
rev |
line source |
peterf@2
|
1 #!/usr/bin/env python
|
peterf@2
|
2 # CREATED:2014-01-18 14:09:05 by Brian McFee <brm2132@columbia.edu>
|
peterf@2
|
3 # unit tests for util routines
|
peterf@2
|
4
|
peterf@2
|
5 import numpy as np
|
peterf@2
|
6 import librosa
|
peterf@2
|
7
|
peterf@2
|
8 def test_frame():
|
peterf@2
|
9
|
peterf@2
|
10 # Generate a random time series
|
peterf@2
|
11 def __test(P):
|
peterf@2
|
12 frame, hop = P
|
peterf@2
|
13
|
peterf@2
|
14 y = np.random.randn(8000)
|
peterf@2
|
15 y_frame = librosa.util.frame(y, frame_length=frame, hop_length=hop)
|
peterf@2
|
16
|
peterf@2
|
17 for i in xrange(y_frame.shape[1]):
|
peterf@2
|
18 assert np.allclose(y_frame[:, i], y[ i * hop : (i * hop + frame)])
|
peterf@2
|
19
|
peterf@2
|
20 for frame in [256, 1024, 2048]:
|
peterf@2
|
21 for hop_length in [64, 256, 512]:
|
peterf@2
|
22 yield (__test, [frame, hop_length])
|