Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions audiomate/corpus/io/tatoeba.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from audiomate.utils import download
from audiomate.utils import textfile
from . import base
import time

logger = logutil.getLogger()

Expand Down Expand Up @@ -137,6 +138,15 @@ def _download_audio_files(self, records, target_path):
os.makedirs(audio_folder, exist_ok=True)

download_url = 'https://audio.tatoeba.org/sentences/{}/{}.mp3'.format(record[2], record[0])
while True:
try:
download.download_file(download_url, audio_file)
except ConnectionError as e:
logger.info('Remote end closed connection without response. Trying again in 5 seconds... %s', e)
time.sleep(5)
continue
break

download.download_file(download_url, audio_file)


Expand Down
10 changes: 9 additions & 1 deletion audiomate/corpus/io/voxforge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import tarfile
import shutil
import time

import requests

Expand Down Expand Up @@ -90,7 +91,14 @@ def download_files(self, file_urls, target_path):
target_file_path = os.path.join(target_path, file_name)
url_to_target[file_url] = target_file_path

dl_result = download.download_files(url_to_target, num_threads=self.num_workers)
while True:
try:
dl_result = download.download_files(url_to_target, num_threads=self.num_workers)
except ConnectionError as e:
logger.info('Remote end closed connection without response. Trying again in 5 seconds... %s', e)
time.sleep(5)
continue
break

downloaded_files = []
for url, status, path_or_msg in dl_result:
Expand Down