urlretrieve_progress is not in the lhoste, in latest version of icefall and lhoste

This commit is contained in:
j-pong 2023-06-12 14:19:41 +09:00
parent 71e20b46fc
commit 058c72b7d2
2 changed files with 15 additions and 2 deletions

View File

@ -12,7 +12,20 @@ from lhotse import (
SupervisionSet, SupervisionSet,
validate_recordings_and_supervisions, validate_recordings_and_supervisions,
) )
from lhotse.utils import Pathlike, safe_extract, urlretrieve_progress from lhotse.utils import Pathlike, safe_extract
def urlretrieve_progress(url, filename=None, data=None, desc=None):
"""
Works exactly like urllib.request.urlretrieve, but attaches a tqdm hook to
display a progress bar of the download.
Use "desc" argument to display a user-readable string that informs what is
being downloaded.
"""
from urllib.request import urlretrieve
with tqdm(unit="B", unit_scale=True, unit_divisor=1024, miniters=1, desc=desc) as t:
reporthook = tqdm_urlretrieve_hook(t)
return urlretrieve(url=url, filename=filename, reporthook=reporthook, data=data)
def prepare_tedlium( def prepare_tedlium(
tedlium_root: Pathlike, output_dir: Optional[Pathlike] = None tedlium_root: Pathlike, output_dir: Optional[Pathlike] = None

View File

@ -55,7 +55,7 @@ if [ $stage -le 0 ] && [ $stop_stage -ge 0 ]; then
# If you have pre-downloaded it to /path/to/tedlium3, # If you have pre-downloaded it to /path/to/tedlium3,
# you can create a symlink # you can create a symlink
# #
# ln -sfv /path/to/tedlium3 $dl_dir/tedlium3 # ln -sfv $dl_dir/TEDLIUM_release-3 $dl_dir/tedlium3
# #
if [ ! -d $dl_dir/tedlium3 ]; then if [ ! -d $dl_dir/tedlium3 ]; then
lhotse download tedlium $dl_dir lhotse download tedlium $dl_dir