added download scripts

This commit is contained in:
Alexander Richard 2024-06-09 15:48:49 -04:00
parent b51d8deaf0
commit 55de23d9a1
2 changed files with 65 additions and 0 deletions

32
download_blind_testset.py Normal file
View file

@ -0,0 +1,32 @@
"""
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import urllib.request
import zipfile
def download_file(url, filename):
with urllib.request.urlopen(url) as response:
data = response.read()
with open(filename, 'wb') as file:
file.write(data)
def unzip_file(zip_path, extract_to):
os.makedirs(extract_to, exist_ok=True)
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_to)
print("downloading blind testset (1.4GB)...")
url = "https://github.com/facebookresearch/ears_dataset/releases/download/blind_testset/blind_testset.zip"
file = f"blind_testset.zip"
download_file(url, file)
unzip_file(file, "blind_testset")
os.remove(file)

33
download_ears.py Normal file
View file

@ -0,0 +1,33 @@
"""
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import tqdm
import urllib.request
import zipfile
def download_file(url, filename):
with urllib.request.urlopen(url) as response:
data = response.read()
with open(filename, 'wb') as file:
file.write(data)
def unzip_file(zip_path, extract_to):
os.makedirs(extract_to, exist_ok=True)
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_to)
for i in tqdm.tqdm(range(1, 108), desc="download 107 speakers of EARS dataset"):
url = f"https://github.com/facebookresearch/ears_dataset/releases/download/dataset/p{i:03d}.zip"
file = f"p{i:03d}.zip"
download_file(url, file)
unzip_file(file, ".")
os.remove(file)