init
Browse files- download_audio.py +3 -1
- main.sh +2 -0
download_audio.py
CHANGED
@@ -102,6 +102,7 @@ def get_audio(dataframe: pd.DataFrame):
|
|
102 |
features[f"{side}.path"] = str(p_join(cache_dir_audio, side, f"{features['line_no']}.{identifier}"))
|
103 |
start, end = features[f"{side}.duration_start"], features[f"{side}.duration_end"]
|
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")
|
@@ -112,9 +113,10 @@ def get_audio(dataframe: pd.DataFrame):
|
|
112 |
return None
|
113 |
else:
|
114 |
try:
|
|
|
115 |
wav = audio_loader.decode_example({"path": features[f"{side}.path"], "bytes": None})
|
116 |
if wav["sampling_rate"] != sampling_rate:
|
117 |
-
print(f"RESAMPLING: {wav['array']} length audio")
|
118 |
if torch.cuda.is_available():
|
119 |
wav["array"] = julius.resample_frac(
|
120 |
torch.as_tensor(wav["array"]).to("cuda"),
|
|
|
102 |
features[f"{side}.path"] = str(p_join(cache_dir_audio, side, f"{features['line_no']}.{identifier}"))
|
103 |
start, end = features[f"{side}.duration_start"], features[f"{side}.duration_end"]
|
104 |
if not os.path.exists(features[f"{side}.path"]):
|
105 |
+
print(f"WGET {features[f'{side}.url']}")
|
106 |
flag = wget(features[f"{side}.url"], output_file=features[f"{side}.path"])
|
107 |
if not flag:
|
108 |
print("\n#### ERROR: wget failure ####\n")
|
|
|
113 |
return None
|
114 |
else:
|
115 |
try:
|
116 |
+
print(f"LOAD AUDIO FROM {features[f'{side}.path']}")
|
117 |
wav = audio_loader.decode_example({"path": features[f"{side}.path"], "bytes": None})
|
118 |
if wav["sampling_rate"] != sampling_rate:
|
119 |
+
print(f"RESAMPLING: {len(wav['array'])} length audio")
|
120 |
if torch.cuda.is_available():
|
121 |
wav["array"] = julius.resample_frac(
|
122 |
torch.as_tensor(wav["array"]).to("cuda"),
|
main.sh
CHANGED
@@ -2,6 +2,8 @@ rm -rf download/audio
|
|
2 |
rm -rf download/feature
|
3 |
python -c 'n=41; import os; from glob import glob; tmp = [int(os.path.basename(i).split(".")[0]) for i in glob("download/feature/enA-jaA/*.json")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
4 |
python -c 'n=41; import os; from glob import glob; tmp = [int(os.path.basename(i).split(".")[0]) for i in glob("download/audio/enA-jaA/enA/*")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
|
|
|
|
5 |
####################
|
6 |
# enA-jaA: 718_606 #
|
7 |
####################
|
|
|
2 |
rm -rf download/feature
|
3 |
python -c 'n=41; import os; from glob import glob; tmp = [int(os.path.basename(i).split(".")[0]) for i in glob("download/feature/enA-jaA/*.json")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
4 |
python -c 'n=41; import os; from glob import glob; tmp = [int(os.path.basename(i).split(".")[0]) for i in glob("download/audio/enA-jaA/enA/*")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
5 |
+
export CUDA_VISIBLE_DEVICES=
|
6 |
+
file_name='download/audio/enA-jaA/jaA/100020.mp3'; from datasets import Audio; a=Audio(); a.decode_example({"path": file_name, "bytes": None})
|
7 |
####################
|
8 |
# enA-jaA: 718_606 #
|
9 |
####################
|