Skip to content

Commit

Permalink
fix: ras Tokens need time&dur, not start&end
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Dec 6, 2024
1 parent c0b13a8 commit 38633c3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fs2/prediction_writing_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 38633c3

Please sign in to comment.