asahi417 commited on
Commit
29dac43
·
1 Parent(s): f4b03a9
Files changed (1) hide show
  1. download_audio.py +4 -7
download_audio.py CHANGED
@@ -1,6 +1,3 @@
1
- """
2
- https://stackoverflow.com/questions/31353244/how-to-config-wget-to-retry-more-than-20
3
- """
4
  import json
5
  import os
6
  import tarfile
@@ -10,7 +7,7 @@ import subprocess
10
  from os.path import join as p_join
11
  from tqdm import tqdm
12
  from multiprocessing import Pool
13
- from typing import Optional, List
14
 
15
  import pandas as pd
16
 
@@ -59,10 +56,10 @@ def wget(url: str, cache_dir: str, filename: Optional[str] = None):
59
  def get_metadata():
60
  url_metadata = url_metadata_dict[direction]
61
  meta_data_filename = os.path.basename(url_metadata).replace(".gz", "")
62
- cache_dir_metadata = p_join("download", "meta", meta_data_filename)
63
- if not os.path.exists(cache_dir_metadata):
64
  assert wget(url_metadata, cache_dir=cache_dir_metadata)
65
- df = pd.read_csv(meta_data_filename, sep=r'[\t\s]', header=None)[[0, 2, 6, 9, 10, 11, 12]]
66
  df.columns = ["id", "url", "text_lid_score", "laser_score", "direction", "side", "line_no"]
67
  assert len(df["direction"].unique()) == 1
68
  df.pop("direction")
 
 
 
 
1
  import json
2
  import os
3
  import tarfile
 
7
  from os.path import join as p_join
8
  from tqdm import tqdm
9
  from multiprocessing import Pool
10
+ from typing import Optional
11
 
12
  import pandas as pd
13
 
 
56
  def get_metadata():
57
  url_metadata = url_metadata_dict[direction]
58
  meta_data_filename = os.path.basename(url_metadata).replace(".gz", "")
59
+ cache_dir_metadata = p_join("download", "meta")
60
+ if not os.path.exists(p_join(cache_dir_metadata, meta_data_filename)):
61
  assert wget(url_metadata, cache_dir=cache_dir_metadata)
62
+ df = pd.read_csv(p_join(cache_dir_metadata, meta_data_filename), sep=r'[\t\s]', header=None)[[0, 2, 6, 9, 10, 11, 12]]
63
  df.columns = ["id", "url", "text_lid_score", "laser_score", "direction", "side", "line_no"]
64
  assert len(df["direction"].unique()) == 1
65
  df.pop("direction")