init
Browse files- .gitignore +1 -1
- download_audio.py +2 -6
- main.sh +9 -0
.gitignore
CHANGED
@@ -3,4 +3,4 @@ build
|
|
3 |
preprocess
|
4 |
download
|
5 |
__pycache__
|
6 |
-
.DS_Store
|
|
|
3 |
preprocess
|
4 |
download
|
5 |
__pycache__
|
6 |
+
.DS_Store
|
download_audio.py
CHANGED
@@ -6,13 +6,12 @@ import gzip
|
|
6 |
import subprocess
|
7 |
from os.path import join as p_join
|
8 |
|
9 |
-
import torch
|
10 |
from tqdm import tqdm
|
11 |
from multiprocessing import Pool
|
12 |
from typing import Optional, Dict
|
13 |
from glob import glob
|
|
|
14 |
|
15 |
-
import julius
|
16 |
import pandas as pd
|
17 |
import soundfile as sf
|
18 |
from datasets import Dataset, Audio, DatasetDict
|
@@ -129,11 +128,8 @@ def get_audio(dataframe: pd.DataFrame):
|
|
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 =
|
137 |
if start < end <= len(wav):
|
138 |
sf.write(features[f"{side}.path"], wav[start:end], sampling_rate)
|
139 |
else:
|
|
|
6 |
import subprocess
|
7 |
from os.path import join as p_join
|
8 |
|
|
|
9 |
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
|
17 |
from datasets import Dataset, Audio, DatasetDict
|
|
|
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 |
+
wav = librosa.resample(wav, orig_sr=sr, target_sr=sr)
|
133 |
if start < end <= len(wav):
|
134 |
sf.write(features[f"{side}.path"], wav[start:end], sampling_rate)
|
135 |
else:
|
main.sh
CHANGED
@@ -20,6 +20,15 @@ python -c 'n=10; import os; from glob import glob; tmp = [int(os.path.basename(i
|
|
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 |
####################
|
|
|
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 |
+
# test
|
24 |
+
export N_POOL=1
|
25 |
+
export DATASET_ID=1
|
26 |
+
export DIRECTION="enA-jaA"
|
27 |
+
export LINE_NO_START=$(((DATASET_ID-1) * 2500))
|
28 |
+
export LINE_NO_END=$((DATASET_ID * 2500))
|
29 |
+
echo ${LINE_NO_START}
|
30 |
+
python download_audio.py
|
31 |
+
|
32 |
####################
|
33 |
# enA-jaA: 718_606 #
|
34 |
####################
|