-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_asv17.py
executable file
·55 lines (43 loc) · 1.76 KB
/
load_asv17.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
import argparse
import os
import subprocess
from pathlib import Path
from urllib.parse import urlparse
URLS_TO_LOAD = [
"https://datashare.ed.ac.uk/bitstream/handle/10283/3055/protocol_V2.zip",
"https://datashare.ed.ac.uk/bitstream/handle/10283/3055/ASVspoof2017_V2_dev.zip",
"https://datashare.ed.ac.uk/bitstream/handle/10283/3055/ASVspoof2017_V2_train.zip",
"https://datashare.ed.ac.uk/bitstream/handle/10283/3055/ASVspoof2017_V2_eval.zip",
]
def run_sh(command: str, cwd: str = None):
after_strip = map(lambda s: s.strip(), command.split(' '))
after_filter = filter(None, after_strip)
after_filter = list(after_filter)
process = subprocess.Popen(after_filter,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=cwd)
stdout, stderr = process.communicate()
return stdout.decode('utf-8'), stderr.decode('utf-8')
def load_artefacts(folder):
cwd = os.getcwd()
folder = Path(folder).resolve()
folder.mkdir(exist_ok=True, parents=True)
os.chdir(folder)
for url in URLS_TO_LOAD:
fn = Path(urlparse(url).path).name
wget_command = f"wget -O {fn} {url}"
out, err = run_sh(wget_command)
unzip_command = f"unzip {fn}"
out, err = run_sh(unzip_command)
rm_command = f"rm {fn}"
out, err = run_sh(unzip_command)
os.chdir(cwd)
if __name__ == "__main__":
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("target_folder",
type=str,
help="Folder to where load ASVSpoof 2017 dataset")
args = parser.parse_args()
load_artefacts(args.target_folder)