From 586154d78a2bd04b61f2e4bc34f41e0fcf4c2499 Mon Sep 17 00:00:00 2001 From: David Huggins-Daines Date: Tue, 31 Jan 2023 15:53:27 -0500 Subject: [PATCH] fix: words may not be aligned (e.g. do-not-align) --- readalongs/align.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readalongs/align.py b/readalongs/align.py index 4b999324..c7fa03e7 100644 --- a/readalongs/align.py +++ b/readalongs/align.py @@ -536,7 +536,9 @@ def add_alignments( } # FIXME: Should propagate durations to higher-level elements, ideally for el in results["tokenized"].xpath("//w"): - el.attrib["time"], el.attrib["dur"] = words_dict[el.attrib["id"]] + # It may not be aligned + if el.attrib["id"] in words_dict: + el.attrib["time"], el.attrib["dur"] = words_dict[el.attrib["id"]] def align_audio(