fix "words" in json response

This commit is contained in:
2024-07-11 21:14:07 +08:00
parent 8b766d0ce1
commit 4ed1c695fe

View File

@@ -126,6 +126,7 @@ def stream_builder(
language=language,
task=task,
initial_prompt=initial_prompt,
word_timestamps=True,
)
print(
"Detected language '%s' with probability %f"
@@ -139,6 +140,8 @@ def stream_builder(
pbar.update(end - last_pos)
last_pos = end
data = segment._asdict()
if data.get('words') is not None:
data["words"] = [i._asdict() for i in data["words"]]
data["total"] = info.duration
yield data