Example #1
0
 def test_silence_low_only(self):
     signal = sp.Signal(np.zeros(8000) + 1e-10, 2000)
     voiced = silence.remove(signal)
     self.assertEqual(voiced.size, 0)
Example #2
0
 def test_silence_empty_signal(self):
     signal = sp.Signal([], 16000)
     voiced = silence.remove(signal)
     self.assertEqual(voiced.size, 0)
Example #3
0
 def test_silence_no_sil_high(self):
     signal = sp.Signal(np.zeros(32000) + 1e5, 8000)
     voiced = silence.remove(signal)
     pading = 40
     self.assertLessEqual(voiced.size - pading, signal.size)
Example #4
0
 def test_zero_silence_only_input(self):
     signal = sp.Signal(np.zeros(32000), 16000)
     voiced = silence.remove(signal)
     pading = 80
     self.assertLessEqual(voiced.size - pading, signal.size)
Example #5
0
 def test_voiced_smaller(self):
     amps = np.zeros(32000)
     amps[2000:4000] += 1
     signal = sp.Signal(amps, 16000)
     voiced = silence.remove(signal)
     self.assertLessEqual(voiced.size, 8000)
 def test_zero_as_max(self):
     signal = sp.Signal(np.arange(2 * 200) * 0.0, 200)
     normalised_signal = sp.normalise(signal)
     expected = np.arange(2 * 200) * 0.0
     self.assertNumpyArrayEqual(expected, normalised_signal.amps)
 def test_negative_amps(self):
     signal = sp.Signal(np.arange(-300, 100), 200)
     normalised_signal = sp.normalise(signal)
     expected = np.arange(-300, 100) / 300
     self.assertNumpyArrayEqual(expected, normalised_signal.amps)
 def test_inside(self):
     signal = sp.Signal(np.arange(2 * 200), 200)
     normalised_signal = sp.normalise(signal)
     expected = np.arange(2 * 200) / 399
     self.assertNumpyArrayEqual(expected, normalised_signal.amps)