Пример #1
0
def test_removesf():
    x = np.random.randn(2 * FS, )
    y = np.random.randn(2 * FS, )
    x_m = matlab.double(list(x))
    y_m = matlab.double(list(y))
    xs, ys = remove_silent_frames(x, y, DYN_RANGE, N_FRAME, N_FRAME / 2)
    xs_m, ys_m = eng.removeSilentFrames(x_m,
                                        y_m,
                                        float(DYN_RANGE),
                                        float(N_FRAME),
                                        float(N_FRAME / 2),
                                        nargout=2)
    xs_m, ys_m = np.array(xs_m._data), np.array(ys_m._data)
    assert_allclose(xs, xs_m, atol=ATOL)
    assert_allclose(ys, ys_m, atol=ATOL)
Пример #2
0
def test_removesf():
    """Test remove_silent_frames by comparing to Octave"""
    # Initialize
    x = np.random.randn(2 * FS)
    y = np.random.randn(2 * FS)
    # Add silence segment
    silence = np.zeros(3 * NFFT, )
    x = np.concatenate([x[:FS], silence, x[FS:]])
    y = np.concatenate([y[:FS], silence, y[FS:]])
    xs, ys = remove_silent_frames(x, y, DYN_RANGE, N_FRAME, N_FRAME // 2)
    xs_m, ys_m = octave.feval('octave/removeSilentFrames.m',
                              x, y, float(DYN_RANGE),
                              float(N_FRAME),
                              float(N_FRAME / 2),
                              nout=2)
    xs_m = np.squeeze(xs_m)
    ys_m = np.squeeze(ys_m)
    assert_allclose(xs, xs_m, atol=ATOL)
    assert_allclose(ys, ys_m, atol=ATOL)
Пример #3
0
def test_removesf():
    # Initialize
    x = np.random.randn(2 * FS, )
    y = np.random.randn(2 * FS, )
    # Add silence segment
    silence = np.zeros(3 * NFFT, )
    x = np.concatenate([x[:FS], silence, x[FS:]])
    y = np.concatenate([y[:FS], silence, y[FS:]])
    x_m = matlab.double(list(x))
    y_m = matlab.double(list(y))
    xs, ys = remove_silent_frames(x, y, DYN_RANGE, N_FRAME, N_FRAME / 2)
    xs_m, ys_m = eng.removeSilentFrames(x_m,
                                        y_m,
                                        float(DYN_RANGE),
                                        float(N_FRAME),
                                        float(N_FRAME / 2),
                                        nargout=2)
    xs_m, ys_m = np.array(xs_m._data), np.array(ys_m._data)
    assert_allclose(xs, xs_m, atol=ATOL)
    assert_allclose(ys, ys_m, atol=ATOL)