init
Browse files- download_audio.py +12 -1
- main.sh +2 -0
download_audio.py
CHANGED
@@ -114,7 +114,18 @@ def get_audio(dataframe: pd.DataFrame):
|
|
114 |
try:
|
115 |
wav = audio_loader.decode_example({"path": features[f"{side}.path"], "bytes": None})
|
116 |
if wav["sampling_rate"] != sampling_rate:
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"])
|
|
|
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"),
|
121 |
+
wav["sampling_rate"],
|
122 |
+
sampling_rate
|
123 |
+
).cpu().numpy()
|
124 |
+
else:
|
125 |
+
wav["array"] = julius.resample_frac(
|
126 |
+
torch.as_tensor(wav["array"]),
|
127 |
+
wav["sampling_rate"], sampling_rate
|
128 |
+
).numpy()
|
129 |
wav["sampling_rate"] = sampling_rate
|
130 |
if start < end <= len(wav["array"]):
|
131 |
sf.write(features[f"{side}.path"], wav["array"][start:end], wav["sampling_rate"])
|
main.sh
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
rm -rf download/audio
|
2 |
rm -rf download/feature
|
|
|
|
|
3 |
####################
|
4 |
# enA-jaA: 718_606 #
|
5 |
####################
|
|
|
1 |
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 |
####################
|