Пример #1
0
 def test_onset_with_chunk(self):
     sr, waveform = scipy.io.wavfile.read('misc/tapping.wav')
     waveform = waveform.tolist()
     chunk_size = 1024
     actual = []
     start_time = 0.0
     sc = 0
     while len(waveform) > chunk_size:
         if len(actual):
             last_onset = actual[-1]
         else:
             last_onset = None
         onsets, sc = door_buzz_simple.detect_onsets(
             waveform[:chunk_size], -18, sr, 16, 200, start_time,
             last_onset, sc)
         actual.extend(onsets)
         waveform = waveform[chunk_size:]
         start_time = door_buzz_simple.time_sample(start_time, chunk_size,
                                                   sr)
     self.assertEqual(2, len(actual))
     self.assertTrue(actual[0][0])
     self.assertFalse(actual[1][0])
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 29360, sr),
                            actual[0][1], 3)
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 132700, sr),
                            actual[1][1], 3)
Пример #2
0
 def test_onset_detect(self):
     sr, waveform = scipy.io.wavfile.read('sample_stimuli/posA_0.wav')
     actual, _ = door_buzz_simple.detect_onsets(waveform.tolist(), -16, sr, 16)
     self.assertEqual(2, len(actual))
     self.assertTrue(actual[0][0])
     self.assertFalse(actual[1][0])
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 62313, sr), actual[0][1], 3)
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 78175, sr), actual[1][1], 3)
Пример #3
0
 def test_onset_detect(self):
     sr, waveform = scipy.io.wavfile.read('sample_stimuli/posA_0.wav')
     actual, _ = door_buzz_simple.detect_onsets(waveform.tolist(), -16, sr,
                                                16)
     self.assertEqual(2, len(actual))
     self.assertTrue(actual[0][0])
     self.assertFalse(actual[1][0])
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 62313, sr),
                            actual[0][1], 3)
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 78175, sr),
                            actual[1][1], 3)
Пример #4
0
 def test_onset_with_chunk(self):
     sr, waveform = scipy.io.wavfile.read('misc/tapping.wav')
     waveform = waveform.tolist()
     chunk_size = 1024
     actual = []
     start_time = 0.0
     sc = 0
     while len(waveform) > chunk_size:
         if len(actual):
             last_onset = actual[-1]
         else:
             last_onset = None
         onsets, sc = door_buzz_simple.detect_onsets(waveform[:chunk_size], -18, sr, 16, 200, start_time,
                                                     last_onset, sc)
         actual.extend(onsets)
         waveform = waveform[chunk_size:]
         start_time = door_buzz_simple.time_sample(start_time, chunk_size, sr)
     self.assertEqual(2, len(actual))
     self.assertTrue(actual[0][0])
     self.assertFalse(actual[1][0])
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 29360, sr), actual[0][1], 3)
     self.assertAlmostEqual(door_buzz_simple.time_sample(0, 132700, sr), actual[1][1], 3)