init
Browse files- download_audio.py +5 -3
- main.sh +8 -16
download_audio.py
CHANGED
@@ -104,6 +104,7 @@ def cleanup(features, feature_file):
|
|
104 |
|
105 |
|
106 |
def get_audio(dataframe: pd.DataFrame):
|
|
|
107 |
features = {"line_no": int(dataframe.pop('line_no').values[0])}
|
108 |
feature_file = p_join(cache_dir_feature, f'{features["line_no"]}.json')
|
109 |
for side, df in dataframe.groupby("side"):
|
@@ -128,10 +129,11 @@ def get_audio(dataframe: pd.DataFrame):
|
|
128 |
wav = wav[:, 0]
|
129 |
wav = wav[:int(end/sampling_rate * sr) + sr]
|
130 |
if sr != sampling_rate:
|
|
|
|
|
|
|
131 |
print(f"RESAMPLING: {wav.shape} length audio")
|
132 |
-
|
133 |
-
# wav = julius.resample_frac(torch.as_tensor(wav).to("cuda"), sr, sampling_rate).cpu().numpy()
|
134 |
-
wav = julius.resample_frac(torch.as_tensor(wav), sr, sampling_rate).numpy()
|
135 |
if start < end <= len(wav):
|
136 |
sf.write(features[f"{side}.path"], wav[start:end], sampling_rate)
|
137 |
else:
|
|
|
104 |
|
105 |
|
106 |
def get_audio(dataframe: pd.DataFrame):
|
107 |
+
resampler = {}
|
108 |
features = {"line_no": int(dataframe.pop('line_no').values[0])}
|
109 |
feature_file = p_join(cache_dir_feature, f'{features["line_no"]}.json')
|
110 |
for side, df in dataframe.groupby("side"):
|
|
|
129 |
wav = wav[:, 0]
|
130 |
wav = wav[:int(end/sampling_rate * sr) + sr]
|
131 |
if sr != sampling_rate:
|
132 |
+
if sr not in resampler:
|
133 |
+
resampler[sr] = julius.ResampleFrac(sr, sampling_rate)
|
134 |
+
print(f"resampler added: {len(resampler)}")
|
135 |
print(f"RESAMPLING: {wav.shape} length audio")
|
136 |
+
wav = resampler[sr](torch.as_tensor(wav)).numpy()
|
|
|
|
|
137 |
if start < end <= len(wav):
|
138 |
sf.write(features[f"{side}.path"], wav[start:end], sampling_rate)
|
139 |
else:
|
main.sh
CHANGED
@@ -9,19 +9,20 @@ python -c 'n=51; import os; from glob import glob; tmp = [int(os.path.basename(i
|
|
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=1
|
27 |
export DIRECTION="enA-jaA"
|
@@ -30,8 +31,6 @@ export LINE_NO_END=$((DATASET_ID * 2500))
|
|
30 |
echo ${LINE_NO_START}
|
31 |
python download_audio.py
|
32 |
|
33 |
-
|
34 |
-
export CUDA_VISIBLE_DEVICES=0
|
35 |
export N_POOL=10
|
36 |
export DATASET_ID=2
|
37 |
export DIRECTION="enA-jaA"
|
@@ -40,8 +39,6 @@ export LINE_NO_END=$((DATASET_ID * 2500))
|
|
40 |
echo ${LINE_NO_START}
|
41 |
python download_audio.py
|
42 |
|
43 |
-
|
44 |
-
export CUDA_VISIBLE_DEVICES=1
|
45 |
export N_POOL=10
|
46 |
export DATASET_ID=10
|
47 |
export DIRECTION="enA-jaA"
|
@@ -52,9 +49,6 @@ python download_audio.py
|
|
52 |
|
53 |
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
export CUDA_VISIBLE_DEVICES=
|
58 |
export N_POOL=1
|
59 |
export DATASET_ID=41
|
60 |
export DIRECTION="enA-jaA"
|
@@ -63,8 +57,7 @@ export LINE_NO_END=$((DATASET_ID * 2500))
|
|
63 |
echo ${LINE_NO_START}
|
64 |
python download_audio.py
|
65 |
|
66 |
-
export
|
67 |
-
export N_POOL=20
|
68 |
export DATASET_ID=42
|
69 |
export DIRECTION="enA-jaA"
|
70 |
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
@@ -72,8 +65,7 @@ export LINE_NO_END=$((DATASET_ID * 2500))
|
|
72 |
echo ${LINE_NO_START}
|
73 |
python download_audio.py
|
74 |
|
75 |
-
export
|
76 |
-
export N_POOL=20
|
77 |
export DATASET_ID=51
|
78 |
export DIRECTION="enA-jaA"
|
79 |
export LINE_NO_START=$(((DATASET_ID-1) * 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=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]))'
|
13 |
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]))'
|
14 |
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]))'
|
15 |
+
python -c 'n=2; 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=2; 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=2; 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 |
+
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]))'
|
19 |
+
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]))'
|
20 |
+
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]))'
|
21 |
|
22 |
python -c 'file_name="tmp.mp3"; from datasets import Audio; a=Audio(); wav=a.decode_example({"path": file_name, "bytes": None}); print(wav)'
|
23 |
####################
|
24 |
# enA-jaA: 718_606 #
|
25 |
####################
|
|
|
26 |
export N_POOL=1
|
27 |
export DATASET_ID=1
|
28 |
export DIRECTION="enA-jaA"
|
|
|
31 |
echo ${LINE_NO_START}
|
32 |
python download_audio.py
|
33 |
|
|
|
|
|
34 |
export N_POOL=10
|
35 |
export DATASET_ID=2
|
36 |
export DIRECTION="enA-jaA"
|
|
|
39 |
echo ${LINE_NO_START}
|
40 |
python download_audio.py
|
41 |
|
|
|
|
|
42 |
export N_POOL=10
|
43 |
export DATASET_ID=10
|
44 |
export DIRECTION="enA-jaA"
|
|
|
49 |
|
50 |
|
51 |
|
|
|
|
|
|
|
52 |
export N_POOL=1
|
53 |
export DATASET_ID=41
|
54 |
export DIRECTION="enA-jaA"
|
|
|
57 |
echo ${LINE_NO_START}
|
58 |
python download_audio.py
|
59 |
|
60 |
+
export N_POOL=10
|
|
|
61 |
export DATASET_ID=42
|
62 |
export DIRECTION="enA-jaA"
|
63 |
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
|
|
65 |
echo ${LINE_NO_START}
|
66 |
python download_audio.py
|
67 |
|
68 |
+
export N_POOL=10
|
|
|
69 |
export DATASET_ID=51
|
70 |
export DIRECTION="enA-jaA"
|
71 |
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|