Skip to content

Add --progress_bar flag to control progress bar visibility #2600

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions whisper/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,17 @@ def new_segment(
"no_speech_prob": result.no_speech_prob,
}

# show the progress bar when verbose is False (if True, transcribed text will be printed)
# ✅ Show the progress bar only if progress_bar is True AND verbose is not enabled
show_progress = decode_options.pop("progress_bar", True)
if show_progress and (verbose is None or verbose is False):
print("🔄 Starting transcription with progress bar...")
with tqdm.tqdm(
total=content_frames, unit="frames", disable=verbose is not False
total=content_frames,
unit="frames",
disable=not show_progress or verbose is not False,
dynamic_ncols=True,
leave=True,
mininterval=0.1
) as pbar:
last_speech_timestamp = 0.0
# NOTE: This loop is obscurely flattened to make the diff readable.
Expand Down Expand Up @@ -564,6 +572,7 @@ def valid_model_name(name):
parser.add_argument("--threads", type=optional_int, default=0, help="number of threads used by torch for CPU inference; supercedes MKL_NUM_THREADS/OMP_NUM_THREADS")
parser.add_argument("--clip_timestamps", type=str, default="0", help="comma-separated list start,end,start,end,... timestamps (in seconds) of clips to process, where the last end timestamp defaults to the end of the file")
parser.add_argument("--hallucination_silence_threshold", type=optional_float, help="(requires --word_timestamps True) skip silent periods longer than this threshold (in seconds) when a possible hallucination is detected")
parser.add_argument("--progress_bar", type=str2bool, default=True,help="Whether to show a progress bar during transcription")
# fmt: on

args = parser.parse_args().__dict__
Expand Down Expand Up @@ -612,7 +621,7 @@ def valid_model_name(name):
writer_args = {arg: args.pop(arg) for arg in word_options}
for audio_path in args.pop("audio"):
try:
result = transcribe(model, audio_path, temperature=temperature, **args)
result = transcribe(model, audio_path,temperature=temperature,progress_bar=args.pop("progress_bar"),**args)
writer(result, audio_path, **writer_args)
except Exception as e:
traceback.print_exc()
Expand Down