This commit is contained in:
yumoqing 2025-11-06 15:00:02 +08:00
parent c1803a0ede
commit 8236dd18a9

View File

@ -41,17 +41,21 @@ class MyLongTask(LongTasks):
def transcribe(self, model, fpath):
segments, info = model.transcribe(fpath, beam_size=5)
debug(f'{segments=}, {info=}')
segments = list(segments)
debug(f'{segments=}, {info=}')
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,
[[word.start, word.end, word.word] for word in segment.words ]
segment.text
] for segment in segments]
}