Merge pull request #1926 from JRMeyer/progressbar-to-tqdm

Change progressbar to tqdm
This commit is contained in:
Josh Meyer 2021-07-30 17:18:47 -04:00 committed by GitHub
commit 90a067df49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -29,6 +29,7 @@ def main():
"six",
"sox",
"soundfile",
"tqdm",
]
decoder_pypi_dep = ["coqui_stt_ctcdecoder == {}".format(version)]

View File

@ -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