smart transcript fix

This commit is contained in:
Stepan Zuev 2024-04-05 07:00:07 +03:00
parent 871ae700df
commit 6f71fa65fb
1 changed files with 4 additions and 4 deletions

View File

@ -235,10 +235,10 @@ def run(seed, left_margin, right_margin, codec_audio_sr, codec_sr, top_k, top_p,
target_transcript = "" target_transcript = ""
for word in transcribe_state["words_info"]: for word in transcribe_state["words_info"]:
if word["end"] < prompt_end_time: if word["end"] < prompt_end_time:
target_transcript += word["word"] target_transcript += word["word"] + (" " if word["word"][-1] != " " else "")
elif (word["start"] + word["end"]) / 2 < prompt_end_time: elif (word["start"] + word["end"]) / 2 < prompt_end_time:
# include part of the word it it's big, but adjust prompt_end_time # include part of the word it it's big, but adjust prompt_end_time
target_transcript += word["word"] target_transcript += word["word"] + (" " if word["word"][-1] != " " else "")
prompt_end_time = word["end"] prompt_end_time = word["end"]
break break
else: else:
@ -263,13 +263,13 @@ def run(seed, left_margin, right_margin, codec_audio_sr, codec_sr, top_k, top_p,
target_transcript = "" target_transcript = ""
for word in transcribe_state["words_info"]: for word in transcribe_state["words_info"]:
if word["start"] < edit_start_time: if word["start"] < edit_start_time:
target_transcript += word["word"] target_transcript += word["word"] + (" " if word["word"][-1] != " " else "")
else: else:
break break
target_transcript += f" {sentence}" target_transcript += f" {sentence}"
for word in transcribe_state["words_info"]: for word in transcribe_state["words_info"]:
if word["end"] > edit_end_time: if word["end"] > edit_end_time:
target_transcript += word["word"] target_transcript += word["word"] + (" " if word["word"][-1] != " " else "")
else: else:
target_transcript = sentence target_transcript = sentence