Exemplo n.º 1
0
 def test_mirex_with_real_data(self):
     features = read_features('data/drumtrack.mp3')
     tempo_classifier = TempoClassifier('fcn')
     t1, t2, s1 = tempo_classifier.estimate_mirex(features)
     self.assertAlmostEquals(s1, 0.99617153)
     self.assertAlmostEquals(t1, 100.)
     self.assertAlmostEquals(t2, 101.)
Exemplo n.º 2
0
 def test_mirex_tempo_sanity(self):
     tempo_classifier = TempoClassifier('fcn')
     t1, t2, s1 = tempo_classifier.estimate_mirex(self.get_test_data())
     tempo = tempo_classifier.estimate_tempo(self.get_test_data())
     if s1 > 0.5:
         self.assertEqual(tempo, t1)
     else:
         self.assertEqual(tempo, t2)
Exemplo n.º 3
0
 def test_predict(self):
     tempo_classifier = TempoClassifier('fcn')
     predictions = tempo_classifier.estimate(self.get_test_data())
     self.assertEqual(predictions.shape, (2, 256))
     np.testing.assert_array_almost_equal(np.ones(2), np.sum(predictions, axis=1))
     tempi = np.argmax(predictions, axis=1) + 30
     self.assertEqual(tempi[0], 163)
     self.assertEqual(tempi[1], 43)
Exemplo n.º 4
0
 def calculateTempo(self):
     model_name = 'cnn'
     classifier = TempoClassifier(model_name)
     features = read_features(self.details["song_file"])
     tempo = classifier.estimate_tempo(features, interpolate=False)
     self.details["bpm"] = tempo
Exemplo n.º 5
0
 def test_init(self):
     tempo_classifier = TempoClassifier('fcn')
     self.assertIsNotNone(tempo_classifier.model)
Exemplo n.º 6
0
 def test_tempo_with_real_data(self):
     features = read_features('data/drumtrack.mp3')
     tempo_classifier = TempoClassifier('fcn')
     tempo = tempo_classifier.estimate_tempo(features)
     self.assertAlmostEqual(100., tempo)
Exemplo n.º 7
0
 def test_predict_mirex(self):
     tempo_classifier = TempoClassifier('fcn')
     t1, t2, s1 = tempo_classifier.estimate_mirex(self.get_test_data())
     self.assertAlmostEquals(s1, 0.7373429)
     self.assertAlmostEquals(t1, 43.)
     self.assertAlmostEquals(t2, 86.)
Exemplo n.º 8
0
 def test_predict_tempo(self):
     tempo_classifier = TempoClassifier('fcn')
     tempo = tempo_classifier.estimate_tempo(self.get_test_data())
     self.assertAlmostEqual(43., tempo)
Exemplo n.º 9
0
 def test_bad_model_name(self):
     try:
         TempoClassifier('bad_model_name')
         self.fail('Expected FileNotFoundError')
     except FileNotFoundError:
         pass