Freeze independent DTW speech timing diagnostic and startup provenance
This commit is contained in:
1 parent
705500425a
commit
3ac1201909
9 files changed
+250
-27
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import unittest
|
||||
from dtw_alignment import aligned_segments
|
||||
|
||||
|
||||
class DtwTests(unittest.TestCase):
|
||||
def raw(self):
|
||||
return {"transcription": [{"text": " Hello. Again!", "offsets": {"from": 0, "to": 1000},
|
||||
"tokens": [{"id": 100, "text": " Hello.", "t_dtw": 20, "offsets": {"from": 900, "to": 100}},
|
||||
{"id": 101, "text": " Again!", "t_dtw": 70}]}]}
|
||||
|
||||
def test_points_are_centiseconds_and_ordinary_reversal_not_repaired(self):
|
||||
result = aligned_segments(self.raw(), 30000, 1000)
|
||||
self.assertEqual([(r["start_ms"], r["end_ms"]) for r in result], [(30200, 30200), (30700, 30700)])
|
||||
self.assertEqual("".join(r["text"] for r in result), " Hello. Again!")
|
||||
|
||||
def test_invalid_missing_fractional_and_nonmonotonic_points_rejected(self):
|
||||
for point in [-1, 101, 1.5, None, 10]:
|
||||
raw = self.raw()
|
||||
raw["transcription"][0]["tokens"][1]["t_dtw"] = point
|
||||
with self.assertRaises(ValueError):
|
||||
aligned_segments(raw, 0, 1000)
|
||||
Reference in new issue
Block a user