Add lazy piano transcription and optional leased server worker

This commit is contained in:
Jonathan Sykes
2026-10-03 15:47:53 +08:00
parent d4354d220e
commit 0374e19396
20 changed files with 1107 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
import unittest
from worker import compact
class CompactNotesTest(unittest.TestCase):
def test_hand_split_and_velocity(self):
notes = compact([{'midi_note': 48, 'onset_time': 1.23456, 'offset_time': 1.78, 'velocity': 85}, {'midi_note': 60, 'onset_time': 2, 'offset_time': 3, 'velocity': 200}])
self.assertEqual(notes[0], {'pitch': 48, 'start': 1.235, 'end': 1.78, 'velocity': 85, 'hand': 'left'})
self.assertEqual(notes[1]['hand'], 'right')
self.assertEqual(notes[1]['velocity'], 127)
def test_empty_or_zero_duration(self):
self.assertEqual(compact([]), [])
self.assertEqual(compact([{'midi_note': 60, 'onset_time': 2, 'offset_time': 2, 'velocity': 85}]), [])
if __name__ == '__main__':
unittest.main()