init
Browse files- download_audio.py +9 -14
- main.sh +67 -3
download_audio.py
CHANGED
@@ -122,23 +122,18 @@ def get_audio(dataframe: pd.DataFrame):
|
|
122 |
else:
|
123 |
try:
|
124 |
print(f"LOAD AUDIO FROM {features[f'{side}.path']}")
|
125 |
-
wav =
|
126 |
-
if wav
|
127 |
-
|
|
|
|
|
|
|
128 |
if torch.cuda.is_available():
|
129 |
-
wav
|
130 |
-
torch.as_tensor(wav["array"]).to("cuda"),
|
131 |
-
wav["sampling_rate"],
|
132 |
-
sampling_rate
|
133 |
-
).cpu().numpy()
|
134 |
else:
|
135 |
-
wav
|
136 |
-
torch.as_tensor(wav["array"]),
|
137 |
-
wav["sampling_rate"], sampling_rate
|
138 |
-
).numpy()
|
139 |
-
wav["sampling_rate"] = sampling_rate
|
140 |
if start < end <= len(wav["array"]):
|
141 |
-
sf.write(features[f"{side}.path"], wav[
|
142 |
else:
|
143 |
print(f"\n#### ERROR ####\n truncation error: {start}, {end}, {len(wav['array'])}")
|
144 |
cleanup(features, feature_file)
|
|
|
122 |
else:
|
123 |
try:
|
124 |
print(f"LOAD AUDIO FROM {features[f'{side}.path']}")
|
125 |
+
wav, sr = sf.read(features[f"{side}.path"])
|
126 |
+
if wav.ndim > 1:
|
127 |
+
wav = wav[:, 0]
|
128 |
+
# wav = audio_loader.decode_example({"path": features[f"{side}.path"], "bytes": None})
|
129 |
+
if sr != sampling_rate:
|
130 |
+
print(f"RESAMPLING: {wav.shape} length audio")
|
131 |
if torch.cuda.is_available():
|
132 |
+
wav = julius.resample_frac(torch.as_tensor(wav).to("cuda"), sr, sampling_rate).cpu().numpy()
|
|
|
|
|
|
|
|
|
133 |
else:
|
134 |
+
wav = julius.resample_frac(torch.as_tensor(wav), sr, sampling_rate).numpy()
|
|
|
|
|
|
|
|
|
135 |
if start < end <= len(wav["array"]):
|
136 |
+
sf.write(features[f"{side}.path"], wav[start:end], sampling_rate)
|
137 |
else:
|
138 |
print(f"\n#### ERROR ####\n truncation error: {start}, {end}, {len(wav['array'])}")
|
139 |
cleanup(features, feature_file)
|
main.sh
CHANGED
@@ -1,13 +1,51 @@
|
|
1 |
-
export CUDA_VISIBLE_DEVICES=
|
|
|
2 |
rm -rf download/audio
|
3 |
rm -rf download/feature
|
4 |
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]))'
|
5 |
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]))'
|
6 |
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/jaA/*")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
7 |
-
python -c '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
####################
|
9 |
# enA-jaA: 718_606 #
|
10 |
####################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
for i in $(seq 1 10);
|
12 |
do
|
13 |
export DATASET_ID=${i}
|
@@ -69,9 +107,35 @@ do
|
|
69 |
python download_audio.py
|
70 |
done
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
for i in $(seq 51 60);
|
73 |
do
|
74 |
-
export N_POOL=
|
75 |
export DATASET_ID=${i}
|
76 |
export DIRECTION="enA-jaA"
|
77 |
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
|
|
1 |
+
export CUDA_VISIBLE_DEVICES=0
|
2 |
+
export CUDA_VISIBLE_DEVICES=1
|
3 |
rm -rf download/audio
|
4 |
rm -rf download/feature
|
5 |
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]))'
|
6 |
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]))'
|
7 |
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/jaA/*")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
8 |
+
python -c 'n=51; 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]))'
|
9 |
+
python -c 'n=51; 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]))'
|
10 |
+
python -c 'n=51; import os; from glob import glob; tmp = [int(os.path.basename(i).split(".")[0]) for i in glob("download/audio/enA-jaA/jaA/*")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
11 |
+
|
12 |
+
python -c 'n=10; 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]))'
|
13 |
+
python -c 'n=10; 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]))'
|
14 |
+
python -c 'n=10; import os; from glob import glob; tmp = [int(os.path.basename(i).split(".")[0]) for i in glob("download/audio/enA-jaA/jaA/*")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
15 |
+
python -c 'n=1; 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]))'
|
16 |
+
python -c 'n=1; 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]))'
|
17 |
+
python -c 'n=1; import os; from glob import glob; tmp = [int(os.path.basename(i).split(".")[0]) for i in glob("download/audio/enA-jaA/jaA/*")]; print(len([x for x in tmp if (n-1) * 2500 <= x < n * 2500]))'
|
18 |
+
|
19 |
+
|
20 |
+
python -c 'file_name="tmp.mp3"; from datasets import Audio; a=Audio(); wav=a.decode_example({"path": file_name, "bytes": None}); print(wav)'
|
21 |
####################
|
22 |
# enA-jaA: 718_606 #
|
23 |
####################
|
24 |
+
export CUDA_VISIBLE_DEVICES=
|
25 |
+
export N_POOL=1
|
26 |
+
export DATASET_ID=2
|
27 |
+
export DIRECTION="enA-jaA"
|
28 |
+
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
29 |
+
export LINE_NO_END=$((DATASET_ID * 2500))
|
30 |
+
echo ${LINE_NO_START}
|
31 |
+
python download_audio.py
|
32 |
+
|
33 |
+
export N_POOL=10
|
34 |
+
export DATASET_ID=1
|
35 |
+
export DIRECTION="enA-jaA"
|
36 |
+
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
37 |
+
export LINE_NO_END=$((DATASET_ID * 2500))
|
38 |
+
echo ${LINE_NO_START}
|
39 |
+
python download_audio.py
|
40 |
+
|
41 |
+
export N_POOL=10
|
42 |
+
export DATASET_ID=10
|
43 |
+
export DIRECTION="enA-jaA"
|
44 |
+
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
45 |
+
export LINE_NO_END=$((DATASET_ID * 2500))
|
46 |
+
echo ${LINE_NO_START}
|
47 |
+
python download_audio.py
|
48 |
+
|
49 |
for i in $(seq 1 10);
|
50 |
do
|
51 |
export DATASET_ID=${i}
|
|
|
107 |
python download_audio.py
|
108 |
done
|
109 |
|
110 |
+
export CUDA_VISIBLE_DEVICES=
|
111 |
+
export N_POOL=1
|
112 |
+
export DATASET_ID=42
|
113 |
+
export DIRECTION="enA-jaA"
|
114 |
+
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
115 |
+
export LINE_NO_END=$((DATASET_ID * 2500))
|
116 |
+
echo ${LINE_NO_START}
|
117 |
+
python download_audio.py
|
118 |
+
|
119 |
+
|
120 |
+
export N_POOL=10
|
121 |
+
export DATASET_ID=41
|
122 |
+
export DIRECTION="enA-jaA"
|
123 |
+
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
124 |
+
export LINE_NO_END=$((DATASET_ID * 2500))
|
125 |
+
echo ${LINE_NO_START}
|
126 |
+
python download_audio.py
|
127 |
+
|
128 |
+
export N_POOL=10
|
129 |
+
export DATASET_ID=51
|
130 |
+
export DIRECTION="enA-jaA"
|
131 |
+
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
132 |
+
export LINE_NO_END=$((DATASET_ID * 2500))
|
133 |
+
echo ${LINE_NO_START}
|
134 |
+
python download_audio.py
|
135 |
+
|
136 |
for i in $(seq 51 60);
|
137 |
do
|
138 |
+
export N_POOL=10
|
139 |
export DATASET_ID=${i}
|
140 |
export DIRECTION="enA-jaA"
|
141 |
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|