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..db28ae24 100644 --- a/training/coqui_stt_training/util/downloader.py +++ b/training/coqui_stt_training/util/downloader.py @@ -1,5 +1,6 @@ from os import makedirs, path +from tqdm import tqdm import progressbar import requests @@ -26,17 +27,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