From fb2d99e9e0ceaac1034e323f3cb335bc79fb7e16 Mon Sep 17 00:00:00 2001 From: Josh Meyer Date: Fri, 30 Jul 2021 12:52:09 -0400 Subject: [PATCH 1/2] Change progressbar to tqdm --- setup.py | 1 + .../coqui_stt_training/util/downloader.py | 24 ++++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index 41755018..84b4364a 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ def main(): "six", "sox", "soundfile", + "tqdm", ] decoder_pypi_dep = ["coqui_stt_ctcdecoder == {}".format(version)] diff --git a/training/coqui_stt_training/util/downloader.py b/training/coqui_stt_training/util/downloader.py index f559fb58..92351f4e 100644 --- a/training/coqui_stt_training/util/downloader.py +++ b/training/coqui_stt_training/util/downloader.py @@ -1,18 +1,10 @@ from os import makedirs, path -import progressbar +from tqdm import tqdm import requests from .io import is_remote_path, open_remote, path_exists_remote -SIMPLE_BAR = [ - "Progress ", - progressbar.Bar(), - " ", - progressbar.Percentage(), - " completed", -] - def maybe_download(archive_name, target_dir, archive_url): # If archive file does not exist, download it... @@ -26,17 +18,11 @@ def maybe_download(archive_name, target_dir, archive_url): print('No archive "%s" - downloading...' % archive_path) req = requests.get(archive_url, stream=True) total_size = int(req.headers.get("content-length", 0)) - done = 0 with open_remote(archive_path, "wb") as f: - bar = progressbar.ProgressBar( - max_value=total_size if total_size > 0 else progressbar.UnknownLength, - widgets=SIMPLE_BAR, - ) - - for data in req.iter_content(1024 * 1024): - done += len(data) - f.write(data) - bar.update(done) + with tqdm(total=total_size) as bar: + for data in req.iter_content(1024 * 1024): + f.write(data) + bar.update(len(data)) else: print('Found archive "%s" - not downloading.' % archive_path) return archive_path From da23122cca6fd56b0fdb0fd51a9b6b2adaf883c3 Mon Sep 17 00:00:00 2001 From: Josh Meyer Date: Fri, 30 Jul 2021 13:09:14 -0400 Subject: [PATCH 2/2] Add SIMPLE_BAR for other scripts --- training/coqui_stt_training/util/downloader.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/training/coqui_stt_training/util/downloader.py b/training/coqui_stt_training/util/downloader.py index 92351f4e..db28ae24 100644 --- a/training/coqui_stt_training/util/downloader.py +++ b/training/coqui_stt_training/util/downloader.py @@ -1,10 +1,19 @@ from os import makedirs, path from tqdm import tqdm +import progressbar import requests from .io import is_remote_path, open_remote, path_exists_remote +SIMPLE_BAR = [ + "Progress ", + progressbar.Bar(), + " ", + progressbar.Percentage(), + " completed", +] + def maybe_download(archive_name, target_dir, archive_url): # If archive file does not exist, download it...