mirror of
https://github.com/m-bain/whisperX.git
synced 2025-07-01 18:17:27 -04:00
add on_progress callback
This commit is contained in:
@ -5,7 +5,7 @@ C. Max Bain
|
||||
import math
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Iterable, Optional, Union, List
|
||||
from typing import Iterable, Union, List, Callable, Optional
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
@ -119,6 +119,7 @@ def align(
|
||||
return_char_alignments: bool = False,
|
||||
print_progress: bool = False,
|
||||
combined_progress: bool = False,
|
||||
on_progress: Callable[[int, int], None] = None
|
||||
) -> AlignedTranscriptionResult:
|
||||
"""
|
||||
Align phoneme recognition predictions to known transcription.
|
||||
@ -147,6 +148,9 @@ def align(
|
||||
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}%...")
|
||||
|
||||
if on_progress:
|
||||
on_progress(sdx + 1, total_segments)
|
||||
|
||||
num_leading = len(segment["text"]) - len(segment["text"].lstrip())
|
||||
num_trailing = len(segment["text"]) - len(segment["text"].rstrip())
|
||||
|
Reference in New Issue
Block a user