init
Browse files- download_audio.py +7 -5
- main.sh +4 -6
download_audio.py
CHANGED
@@ -10,7 +10,7 @@ from tqdm import tqdm
|
|
10 |
from multiprocessing import Pool
|
11 |
from typing import Optional, Dict
|
12 |
from glob import glob
|
13 |
-
import librosa
|
14 |
|
15 |
import pandas as pd
|
16 |
import soundfile as sf
|
@@ -128,12 +128,14 @@ def get_audio(dataframe: pd.DataFrame):
|
|
128 |
wav = wav[:, 0]
|
129 |
wav = wav[floor(start / sampling_rate * sr):ceil(end / sampling_rate * sr)]
|
130 |
print(f"wav shape (after truncate):{wav.shape}")
|
131 |
-
|
|
|
|
|
132 |
# if sr != sampling_rate:
|
133 |
# print(f"RESAMPLING: {wav.shape} length audio")
|
134 |
-
# wav = librosa.resample(wav, orig_sr=sr, target_sr=
|
135 |
-
|
136 |
-
|
137 |
except Exception as e:
|
138 |
print(f"\n#### ERROR ####\n {e}")
|
139 |
cleanup(features, feature_file)
|
|
|
10 |
from multiprocessing import Pool
|
11 |
from typing import Optional, Dict
|
12 |
from glob import glob
|
13 |
+
# import librosa
|
14 |
|
15 |
import pandas as pd
|
16 |
import soundfile as sf
|
|
|
128 |
wav = wav[:, 0]
|
129 |
wav = wav[floor(start / sampling_rate * sr):ceil(end / sampling_rate * sr)]
|
130 |
print(f"wav shape (after truncate):{wav.shape}")
|
131 |
+
wav = wav[:int(end/sampling_rate * sr) + sr]
|
132 |
+
print(f"SAVING: {features[f'{side}.path']}")
|
133 |
+
sf.write(features[f"{side}.path"], wav, sr)
|
134 |
# if sr != sampling_rate:
|
135 |
# print(f"RESAMPLING: {wav.shape} length audio")
|
136 |
+
# wav = librosa.resample(wav, orig_sr=sr, target_sr=sampling_rate)
|
137 |
+
# sf.write(features[f"{side}.path"], wav[start:end], sampling_rate)
|
138 |
+
|
139 |
except Exception as e:
|
140 |
print(f"\n#### ERROR ####\n {e}")
|
141 |
cleanup(features, feature_file)
|
main.sh
CHANGED
@@ -24,12 +24,10 @@ python -c 'n=10; import os; from glob import glob; tmp = [int(os.path.basename(i
|
|
24 |
|
25 |
python -c 'file_name="tmp.mp3"; from datasets import Audio; a=Audio(); wav=a.decode_example({"path": file_name, "bytes": None}); print(wav)'
|
26 |
# test
|
27 |
-
export
|
28 |
-
export DATASET_ID=1
|
29 |
export DIRECTION="enA-jaA"
|
30 |
-
export LINE_NO_START
|
31 |
-
export LINE_NO_END
|
32 |
-
echo ${LINE_NO_START}
|
33 |
python download_audio.py
|
34 |
|
35 |
####################
|
@@ -61,7 +59,7 @@ python download_audio.py
|
|
61 |
|
62 |
|
63 |
|
64 |
-
export N_POOL=
|
65 |
export DATASET_ID=41
|
66 |
export DIRECTION="enA-jaA"
|
67 |
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
|
|
24 |
|
25 |
python -c 'file_name="tmp.mp3"; from datasets import Audio; a=Audio(); wav=a.decode_example({"path": file_name, "bytes": None}); print(wav)'
|
26 |
# test
|
27 |
+
export DATASET_ID=test
|
|
|
28 |
export DIRECTION="enA-jaA"
|
29 |
+
export LINE_NO_START=0
|
30 |
+
export LINE_NO_END=10
|
|
|
31 |
python download_audio.py
|
32 |
|
33 |
####################
|
|
|
59 |
|
60 |
|
61 |
|
62 |
+
export N_POOL=10
|
63 |
export DATASET_ID=41
|
64 |
export DIRECTION="enA-jaA"
|
65 |
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|