Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: progress callbacks #1033

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions whisperx/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def align(
return_char_alignments: bool = False,
print_progress: bool = False,
combined_progress: bool = False,
progress_callback=None,
) -> AlignedTranscriptionResult:
"""
Align phoneme recognition predictions to known transcription.
Expand Down Expand Up @@ -147,6 +148,8 @@ 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 progress_callback:
progress_callback(percent_complete)

num_leading = len(segment["text"]) - len(segment["text"].lstrip())
num_trailing = len(segment["text"]) - len(segment["text"].rstrip())
Expand Down
3 changes: 3 additions & 0 deletions whisperx/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def transcribe(
print_progress=False,
combined_progress=False,
verbose=False,
progress_callback=None,
) -> TranscriptionResult:
if isinstance(audio, str):
audio = load_audio(audio)
Expand Down Expand Up @@ -258,6 +259,8 @@ def data(audio, segments):
base_progress = ((idx + 1) / total_segments) * 100
percent_complete = base_progress / 2 if combined_progress else base_progress
print(f"Progress: {percent_complete:.2f}%...")
if progress_callback:
progress_callback(percent_complete)
text = out['text']
if batch_size in [0, 1, None]:
text = text[0]
Expand Down