From 38633c38997acfc56cbad93a26886cd105486228 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Fri, 6 Dec 2024 16:31:20 -0500 Subject: [PATCH] fix: ras Tokens need time&dur, not start&end --- fs2/prediction_writing_callback.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs2/prediction_writing_callback.py b/fs2/prediction_writing_callback.py index 027e166..c58946d 100644 --- a/fs2/prediction_writing_callback.py +++ b/fs2/prediction_writing_callback.py @@ -334,12 +334,11 @@ def __init__( def save_text(self, max_seconds, phones, words, language, filename): """Save the aligned text as a .readalong file""" - # Convert the (time, end, label) word tuples into RAS Tokens ras_tokens: list[Token] = [] - for word in words: + for start, end, label in words: if ras_tokens: - ras_tokens.append(Token(" ")) - ras_tokens.append(Token(word[2], word[0], word[1])) + ras_tokens.append(Token(text=" ", is_word=False)) + ras_tokens.append(Token(text=label, time=start, dur=end - start)) readalong = convert_to_readalong([ras_tokens], [language]) with open(filename, "w", encoding="utf8") as f: