Datasets:
michaelnetbiz
commited on
Commit
•
0e7f25e
1
Parent(s):
4049719
Update scripts
Browse files- .run/prep_data.run.xml +2 -2
- scripts/fetch_data.py +0 -26
- scripts/pack_push_to_s3.sh +11 -0
- scripts/{prep_data.py → prep_push_to_hf.py} +6 -4
- scripts/pull_from_s3.py +24 -0
.run/prep_data.run.xml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<component name="ProjectRunConfigurationManager">
|
2 |
-
<configuration default="false" name="
|
3 |
<module name="kendex" />
|
4 |
<option name="INTERPRETER_OPTIONS" value="" />
|
5 |
<option name="PARENT_ENVS" value="true" />
|
@@ -31,7 +31,7 @@
|
|
31 |
<option name="region" />
|
32 |
<option name="useCurrentConnection" value="false" />
|
33 |
</EXTENSION>
|
34 |
-
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/scripts/
|
35 |
<option name="PARAMETERS" value="" />
|
36 |
<option name="SHOW_COMMAND_LINE" value="false" />
|
37 |
<option name="EMULATE_TERMINAL" value="false" />
|
|
|
1 |
<component name="ProjectRunConfigurationManager">
|
2 |
+
<configuration default="false" name="prep_push_to_hf" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
3 |
<module name="kendex" />
|
4 |
<option name="INTERPRETER_OPTIONS" value="" />
|
5 |
<option name="PARENT_ENVS" value="true" />
|
|
|
31 |
<option name="region" />
|
32 |
<option name="useCurrentConnection" value="false" />
|
33 |
</EXTENSION>
|
34 |
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/scripts/prep_push_to_hf.py" />
|
35 |
<option name="PARAMETERS" value="" />
|
36 |
<option name="SHOW_COMMAND_LINE" value="false" />
|
37 |
<option name="EMULATE_TERMINAL" value="false" />
|
scripts/fetch_data.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python3
|
2 |
-
|
3 |
-
import os
|
4 |
-
import boto3
|
5 |
-
import tarfile
|
6 |
-
from pathlib import Path
|
7 |
-
|
8 |
-
DATASET = "kendex.tar.gz"
|
9 |
-
|
10 |
-
repo_root = Path(__file__).resolve().parent.parent
|
11 |
-
|
12 |
-
local_path = os.path.join(repo_root, "data", DATASET)
|
13 |
-
|
14 |
-
if not Path(local_path).exists():
|
15 |
-
s3 = boto3.resource("s3")
|
16 |
-
kendex = s3.Bucket("kendex")
|
17 |
-
kendex.download_file(DATASET, local_path)
|
18 |
-
print("downloaded")
|
19 |
-
|
20 |
-
expanded_path = os.path.join(repo_root, "data", "kendex")
|
21 |
-
|
22 |
-
if not Path(expanded_path).exists():
|
23 |
-
file = tarfile.open(local_path)
|
24 |
-
file.extractall(expanded_path)
|
25 |
-
file.close()
|
26 |
-
print("untar'd, gunzip'd")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/pack_push_to_s3.sh
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
KENDEX_TARBALL="Kendex.tar.gz"
|
4 |
+
|
5 |
+
tar -czf "$KENDEX_TARBALL" \
|
6 |
+
--exclude="*DS_Store" \
|
7 |
+
--exclude="**_bak**" \
|
8 |
+
--include="**Kendex**" \
|
9 |
+
--directory="$HOME/Data/Kendex/Datasets" Kendex
|
10 |
+
|
11 |
+
aws s3 cp "./$KENDEX_TARBALL" "s3://kendex/$KENDEX_TARBALL"
|
scripts/{prep_data.py → prep_push_to_hf.py}
RENAMED
@@ -6,16 +6,18 @@ import huggingface_hub
|
|
6 |
from datasets import Audio, Dataset
|
7 |
import pandas as pd
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
metadata = os.path.join(repo_root, "data", "kendex", "metadata.csv")
|
12 |
-
wavs = os.path.join(repo_root, "data", "kendex", "wavs")
|
13 |
df = pd.read_csv(metadata, delimiter="|", header=None)
|
14 |
|
15 |
dataset = Dataset.from_pandas(
|
16 |
pd.DataFrame(
|
17 |
{
|
18 |
-
"audio": pd.Series([os.path.join(
|
19 |
"text": df[1],
|
20 |
}
|
21 |
)
|
|
|
6 |
from datasets import Audio, Dataset
|
7 |
import pandas as pd
|
8 |
|
9 |
+
repo_dir = Path(__file__).resolve().parent.parent
|
10 |
+
data_dir = os.path.join(repo_dir, "data")
|
11 |
+
kendex_dir = os.path.join(data_dir, "Kendex")
|
12 |
+
audio_dir = os.path.join(kendex_dir, "wavs")
|
13 |
+
metadata = os.path.join(kendex_dir, "metadata.csv")
|
14 |
|
|
|
|
|
15 |
df = pd.read_csv(metadata, delimiter="|", header=None)
|
16 |
|
17 |
dataset = Dataset.from_pandas(
|
18 |
pd.DataFrame(
|
19 |
{
|
20 |
+
"audio": pd.Series([os.path.join(audio_dir, f"{f}.wav") for f in df[0]]),
|
21 |
"text": df[1],
|
22 |
}
|
23 |
)
|
scripts/pull_from_s3.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
|
3 |
+
import os
|
4 |
+
import boto3
|
5 |
+
import tarfile
|
6 |
+
from pathlib import Path
|
7 |
+
|
8 |
+
KENDEX_TARBALL = "Kendex.tar.gz"
|
9 |
+
|
10 |
+
repo_dir = Path(__file__).resolve().parent.parent
|
11 |
+
data_dir = os.path.join(repo_dir, "data")
|
12 |
+
kendex_dir = os.path.join(data_dir, "Kendex")
|
13 |
+
|
14 |
+
if not Path(os.path.join(data_dir, KENDEX_TARBALL)).exists():
|
15 |
+
s3 = boto3.resource("s3")
|
16 |
+
kendex = s3.Bucket("kendex")
|
17 |
+
kendex.download_file(KENDEX_TARBALL, os.path.join(data_dir, KENDEX_TARBALL))
|
18 |
+
print(f"downloaded {KENDEX_TARBALL}")
|
19 |
+
|
20 |
+
if not Path(kendex_dir).exists():
|
21 |
+
file = tarfile.open(os.path.join(data_dir, KENDEX_TARBALL))
|
22 |
+
file.extractall(data_dir)
|
23 |
+
file.close()
|
24 |
+
print(f"extracted {KENDEX_TARBALL}")
|