asahi417 commited on
Commit
5df4440
·
1 Parent(s): ae0e349
Files changed (2) hide show
  1. download_audio.py +6 -3
  2. main.sh +5 -3
download_audio.py CHANGED
@@ -104,9 +104,11 @@ def get_audio(dataframe: pd.DataFrame):
104
  if not os.path.exists(features[f"{side}.path"]):
105
  flag = wget(features[f"{side}.url"], output_file=features[f"{side}.path"])
106
  if not flag:
107
- # create a dummy file to avoid the url again
108
  if os.path.exists(feature_file):
109
  os.remove(feature_file)
 
 
110
  return None
111
  else:
112
  try:
@@ -114,15 +116,16 @@ def get_audio(dataframe: pd.DataFrame):
114
  if wav["sampling_rate"] != sampling_rate:
115
  wav["array"] = julius.resample_frac(torch.as_tensor(wav["array"]), wav["sampling_rate"], sampling_rate)
116
  wav["sampling_rate"] = sampling_rate
117
- if start < end < len(wav["array"]):
118
  sf.write(features[f"{side}.path"], wav["array"][start:end], wav["sampling_rate"])
119
  else:
 
120
  os.remove(features[f"{side}.path"])
121
  if os.path.exists(feature_file):
122
  os.remove(feature_file)
123
  return None
124
  except Exception as e:
125
- print(e)
126
  os.remove(features[f"{side}.path"])
127
  if os.path.exists(feature_file):
128
  os.remove(feature_file)
 
104
  if not os.path.exists(features[f"{side}.path"]):
105
  flag = wget(features[f"{side}.url"], output_file=features[f"{side}.path"])
106
  if not flag:
107
+ print("\n#### ERROR: wget failure ####\n")
108
  if os.path.exists(feature_file):
109
  os.remove(feature_file)
110
+ if os.path.exists(features[f"{side}.path"]):
111
+ os.remove(features[f"{side}.path"])
112
  return None
113
  else:
114
  try:
 
116
  if wav["sampling_rate"] != sampling_rate:
117
  wav["array"] = julius.resample_frac(torch.as_tensor(wav["array"]), wav["sampling_rate"], sampling_rate)
118
  wav["sampling_rate"] = sampling_rate
119
+ if start < end <= len(wav["array"]):
120
  sf.write(features[f"{side}.path"], wav["array"][start:end], wav["sampling_rate"])
121
  else:
122
+ print(f"\n#### ERROR ####\n truncation error: {start}, {end}, {len(wav["array"])}")
123
  os.remove(features[f"{side}.path"])
124
  if os.path.exists(feature_file):
125
  os.remove(feature_file)
126
  return None
127
  except Exception as e:
128
+ print(f"\n#### ERROR ####\n {e}")
129
  os.remove(features[f"{side}.path"])
130
  if os.path.exists(feature_file):
131
  os.remove(feature_file)
main.sh CHANGED
@@ -50,25 +50,27 @@ do
50
  python download_audio.py &
51
  done
52
 
53
-
54
  for i in $(seq 41 50);
55
  do
 
56
  export DATASET_ID=${i}
57
  export DIRECTION="enA-jaA"
58
  export LINE_NO_START=$(((DATASET_ID-1) * 2500))
59
  export LINE_NO_END=$((DATASET_ID * 2500))
60
  echo ${LINE_NO_START}
61
- python download_audio.py &
62
  done
63
 
64
  for i in $(seq 51 60);
65
  do
 
66
  export DATASET_ID=${i}
67
  export DIRECTION="enA-jaA"
68
  export LINE_NO_START=$(((DATASET_ID-1) * 2500))
69
  export LINE_NO_END=$((DATASET_ID * 2500))
70
  echo ${LINE_NO_START}
71
- python download_audio.py &
72
  done
73
 
74
 
 
50
  python download_audio.py &
51
  done
52
 
53
+ # kotoba-4
54
  for i in $(seq 41 50);
55
  do
56
+ export N_POOL=40
57
  export DATASET_ID=${i}
58
  export DIRECTION="enA-jaA"
59
  export LINE_NO_START=$(((DATASET_ID-1) * 2500))
60
  export LINE_NO_END=$((DATASET_ID * 2500))
61
  echo ${LINE_NO_START}
62
+ python download_audio.py
63
  done
64
 
65
  for i in $(seq 51 60);
66
  do
67
+ export N_POOL=40
68
  export DATASET_ID=${i}
69
  export DIRECTION="enA-jaA"
70
  export LINE_NO_START=$(((DATASET_ID-1) * 2500))
71
  export LINE_NO_END=$((DATASET_ID * 2500))
72
  echo ${LINE_NO_START}
73
+ python download_audio.py
74
  done
75
 
76