Change progressbar to tqdm

This commit is contained in:
Josh Meyer 2021-07-30 12:52:09 -04:00
parent df26eca4d2
commit fb2d99e9e0
2 changed files with 6 additions and 19 deletions

View File

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

View File

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