Merge pull request #1926 from JRMeyer/progressbar-to-tqdm
Change progressbar to tqdm
This commit is contained in:
commit
90a067df49
1
setup.py
1
setup.py
|
@ -29,6 +29,7 @@ def main():
|
||||||
"six",
|
"six",
|
||||||
"sox",
|
"sox",
|
||||||
"soundfile",
|
"soundfile",
|
||||||
|
"tqdm",
|
||||||
]
|
]
|
||||||
|
|
||||||
decoder_pypi_dep = ["coqui_stt_ctcdecoder == {}".format(version)]
|
decoder_pypi_dep = ["coqui_stt_ctcdecoder == {}".format(version)]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from os import makedirs, path
|
from os import makedirs, path
|
||||||
|
|
||||||
|
from tqdm import tqdm
|
||||||
import progressbar
|
import progressbar
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -26,17 +27,11 @@ def maybe_download(archive_name, target_dir, archive_url):
|
||||||
print('No archive "%s" - downloading...' % archive_path)
|
print('No archive "%s" - downloading...' % archive_path)
|
||||||
req = requests.get(archive_url, stream=True)
|
req = requests.get(archive_url, stream=True)
|
||||||
total_size = int(req.headers.get("content-length", 0))
|
total_size = int(req.headers.get("content-length", 0))
|
||||||
done = 0
|
|
||||||
with open_remote(archive_path, "wb") as f:
|
with open_remote(archive_path, "wb") as f:
|
||||||
bar = progressbar.ProgressBar(
|
with tqdm(total=total_size) as bar:
|
||||||
max_value=total_size if total_size > 0 else progressbar.UnknownLength,
|
for data in req.iter_content(1024 * 1024):
|
||||||
widgets=SIMPLE_BAR,
|
f.write(data)
|
||||||
)
|
bar.update(len(data))
|
||||||
|
|
||||||
for data in req.iter_content(1024 * 1024):
|
|
||||||
done += len(data)
|
|
||||||
f.write(data)
|
|
||||||
bar.update(done)
|
|
||||||
else:
|
else:
|
||||||
print('Found archive "%s" - not downloading.' % archive_path)
|
print('Found archive "%s" - not downloading.' % archive_path)
|
||||||
return archive_path
|
return archive_path
|
||||||
|
|
Loading…
Reference in New Issue