Update alignment.py

This commit is contained in:
awerks
2023-08-17 14:53:53 +02:00
committed by GitHub
parent ea7bb91a56
commit abbb66b58e

View File

@ -98,7 +98,8 @@ def align(
device: str, device: str,
interpolate_method: str = "nearest", interpolate_method: str = "nearest",
return_char_alignments: bool = False, return_char_alignments: bool = False,
print_progress = False print_progress = False,
combined_progress = False
) -> AlignedTranscriptionResult: ) -> AlignedTranscriptionResult:
""" """
Align phoneme recognition predictions to known transcription. Align phoneme recognition predictions to known transcription.
@ -124,7 +125,8 @@ def align(
for sdx, segment in enumerate(transcript): for sdx, segment in enumerate(transcript):
# strip spaces at beginning / end, but keep track of the amount. # strip spaces at beginning / end, but keep track of the amount.
if print_progress: if print_progress:
percent_complete = ((sdx + 1) / total_segments) * 100 base_progress = ((sdx + 1) / total_segments) * 100
percent_complete = (50 + base_progress / 2) if combined_progress else base_progress
print(f"Progress: {percent_complete:.2f}%...") print(f"Progress: {percent_complete:.2f}%...")
num_leading = len(segment["text"]) - len(segment["text"].lstrip()) num_leading = len(segment["text"]) - len(segment["text"].lstrip())