From ee1f71815223a80bd1264c0458621a9a8aa28859 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 6 Nov 2025 15:16:03 +0800 Subject: [PATCH] bugfix --- fw/fw.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/fw/fw.py b/fw/fw.py index 4fb4916..bd9200a 100644 --- a/fw/fw.py +++ b/fw/fw.py @@ -40,22 +40,17 @@ class MyLongTask(LongTasks): return await f(model, fpath) def transcribe(self, model, fpath): - segments, info = model.transcribe(fpath, beam_size=5) + segments, info = model.transcribe(fpath, beam_size=5, word_timestamps=True) segments = list(segments) debug(f'{segments=}') - words = [] - for s in segments: - if s.words: - words.append([[word.start, word.end, word.word] for word in s.words]) - return { 'language': info.language, 'language_probability': info.language_probability, 'content': ' '.join([s.text for s in segments]), - 'words': words, - 'segments': [[segment.start, - segment.end, - segment.text - ] for segment in segments] + 'segments': [[s.start, + s.end, + s.text, + [[w.start, w.end, w.word] for w in s.words] + ] for s in segments] }