Exemplo n.º 1
0
    def test_default_output_length(self):
        x = th.ones(1, 2, 32000)

        resampler = resample.ResampleFrac(old_sr=32000, new_sr=48000)
        y = resampler(x)
        self.assertEqual(y.shape, (1, 2, 48000))

        # Test functional version as well
        y = resample.resample_frac(x, old_sr=32000, new_sr=48000)
        self.assertEqual(y.shape, (1, 2, 48000))
Exemplo n.º 2
0
    def test_custom_output_length(self):
        x = th.ones(1, 32001)

        resampler = resample.ResampleFrac(old_sr=32000, new_sr=48000)
        y = resampler(x, output_length=48001)
        self.assertEqual(y.shape, (1, 48001))

        # Test functional version as well
        y = resample.resample_frac(x,
                                   old_sr=32000,
                                   new_sr=48000,
                                   output_length=47999)
        self.assertEqual(y.shape, (1, 47999))
Exemplo n.º 3
0
    def test_custom_output_length_extreme_resampling(self):
        """
        Resample a signal from 1 hz to 499 hz to check that custom_length works
        correctly without extra internal padding
        """
        x = th.ones(1, 1)

        resampler = resample.ResampleFrac(old_sr=1, new_sr=499)
        y = resampler(x, output_length=499)
        self.assertEqual(y.shape, (1, 499))

        # Test functional version as well
        y = resample.resample_frac(x, old_sr=1, new_sr=499, output_length=3)
        self.assertEqual(y.shape, (1, 3))
Exemplo n.º 4
0
 def test_torchscript(self):
     mod = resample.ResampleFrac(5, 7)
     x = th.randn(5 * 26)
     jitted = th.jit.script(mod)
     self.assertEqual(list(jitted(x).shape), [7 * 26])