Upload folder using huggingface_hub
Browse files- .idea/workspace.xml +1 -1
- audio_pl.tar +3 -0
- pl_debates_test.py +46 -23
.idea/workspace.xml
CHANGED
|
@@ -59,7 +59,7 @@
|
|
| 59 |
<option name="number" value="Default" />
|
| 60 |
<option name="presentableId" value="Default" />
|
| 61 |
<updated>1748334702944</updated>
|
| 62 |
-
<workItem from="1748334704041" duration="
|
| 63 |
</task>
|
| 64 |
<servers />
|
| 65 |
</component>
|
|
|
|
| 59 |
<option name="number" value="Default" />
|
| 60 |
<option name="presentableId" value="Default" />
|
| 61 |
<updated>1748334702944</updated>
|
| 62 |
+
<workItem from="1748334704041" duration="2124000" />
|
| 63 |
</task>
|
| 64 |
<servers />
|
| 65 |
</component>
|
audio_pl.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e1147c3e27593782716646e3223a8f491d4f25d13f954b1bc0ba07c7be878729
|
| 3 |
+
size 107509760
|
pl_debates_test.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import csv
|
| 3 |
import datasets
|
|
@@ -10,21 +13,34 @@ _CITATION = """
|
|
| 10 |
}
|
| 11 |
"""
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
class PlDebatesTest(datasets.GeneratorBasedBuilder):
|
| 15 |
"""Polish politicians’ speech audio dataset."""
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def _info(self):
|
| 18 |
return datasets.DatasetInfo(
|
| 19 |
-
description="Studio
|
| 20 |
features=datasets.Features({
|
| 21 |
-
"path":
|
| 22 |
-
"audio":
|
| 23 |
-
"sentence":
|
| 24 |
-
"age":
|
| 25 |
-
"gender":
|
| 26 |
"speech_type": datasets.Value("string"),
|
| 27 |
-
"source":
|
| 28 |
}),
|
| 29 |
supervised_keys=None,
|
| 30 |
homepage="https://huggingface.co/datasets/directtt/pl_debates_test",
|
|
@@ -32,28 +48,34 @@ class PlDebatesTest(datasets.GeneratorBasedBuilder):
|
|
| 32 |
)
|
| 33 |
|
| 34 |
def _split_generators(self, dl_manager):
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
return [
|
| 37 |
datasets.SplitGenerator(
|
| 38 |
name=datasets.Split.TEST,
|
| 39 |
-
gen_kwargs={
|
|
|
|
|
|
|
|
|
|
| 40 |
),
|
| 41 |
]
|
| 42 |
|
| 43 |
-
def _generate_examples(self,
|
| 44 |
-
#
|
| 45 |
-
tsv_path = os.path.join(data_dir, "transcript", "pl", "test.tsv")
|
| 46 |
meta = {}
|
| 47 |
with open(tsv_path, encoding="utf-8") as f:
|
| 48 |
reader = csv.DictReader(f, delimiter="\t")
|
| 49 |
for row in reader:
|
| 50 |
meta[row["path"]] = row
|
| 51 |
|
| 52 |
-
#
|
| 53 |
key = 0
|
| 54 |
-
|
| 55 |
-
for speaker in sorted(os.listdir(
|
| 56 |
-
sp_dir = os.path.join(
|
| 57 |
if not os.path.isdir(sp_dir):
|
| 58 |
continue
|
| 59 |
for fname in sorted(os.listdir(sp_dir)):
|
|
@@ -62,14 +84,15 @@ class PlDebatesTest(datasets.GeneratorBasedBuilder):
|
|
| 62 |
rel_path = os.path.join("audio", "pl", speaker, fname)
|
| 63 |
row = meta.get(rel_path)
|
| 64 |
if row is None:
|
|
|
|
| 65 |
continue
|
| 66 |
yield key, {
|
| 67 |
-
"path":
|
| 68 |
-
"audio":
|
| 69 |
-
"sentence":
|
| 70 |
-
"age":
|
| 71 |
-
"gender":
|
| 72 |
-
"speech_type":
|
| 73 |
-
"source":
|
| 74 |
}
|
| 75 |
key += 1
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# pl_debates_test.py
|
| 3 |
+
|
| 4 |
import os
|
| 5 |
import csv
|
| 6 |
import datasets
|
|
|
|
| 13 |
}
|
| 14 |
"""
|
| 15 |
|
| 16 |
+
# Replace YOUR-USER/YOUR-REPO with your actual namespace/repo
|
| 17 |
+
_BASE_URL = "https://huggingface.co/datasets/directtt/pl_debates_test/resolve/main/"
|
| 18 |
+
_TRANSCRIPT_URL = _BASE_URL + "transcript/pl/test.tsv"
|
| 19 |
+
_AUDIO_TAR_URL = _BASE_URL + "audio_pl.tar"
|
| 20 |
+
|
| 21 |
|
| 22 |
class PlDebatesTest(datasets.GeneratorBasedBuilder):
|
| 23 |
"""Polish politicians’ speech audio dataset."""
|
| 24 |
|
| 25 |
+
BUILDER_CONFIGS = [
|
| 26 |
+
datasets.BuilderConfig(
|
| 27 |
+
name="pl_debates_test",
|
| 28 |
+
version=datasets.Version("1.0.0"),
|
| 29 |
+
description="Studio‐recorded short utterances by Polish politicians.",
|
| 30 |
+
)
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
def _info(self):
|
| 34 |
return datasets.DatasetInfo(
|
| 35 |
+
description="Studio‐recorded short utterances by Polish politicians.",
|
| 36 |
features=datasets.Features({
|
| 37 |
+
"path": datasets.Value("string"),
|
| 38 |
+
"audio": datasets.Audio(sampling_rate=16_000),
|
| 39 |
+
"sentence": datasets.Value("string"),
|
| 40 |
+
"age": datasets.Value("int32"),
|
| 41 |
+
"gender": datasets.ClassLabel(names=["male", "female", "unknown"]),
|
| 42 |
"speech_type": datasets.Value("string"),
|
| 43 |
+
"source": datasets.Value("string"),
|
| 44 |
}),
|
| 45 |
supervised_keys=None,
|
| 46 |
homepage="https://huggingface.co/datasets/directtt/pl_debates_test",
|
|
|
|
| 48 |
)
|
| 49 |
|
| 50 |
def _split_generators(self, dl_manager):
|
| 51 |
+
# Download & extract both the TSV and the audio tarball
|
| 52 |
+
downloaded = dl_manager.download_and_extract({
|
| 53 |
+
"tsv": _TRANSCRIPT_URL,
|
| 54 |
+
"tar": _AUDIO_TAR_URL,
|
| 55 |
+
})
|
| 56 |
return [
|
| 57 |
datasets.SplitGenerator(
|
| 58 |
name=datasets.Split.TEST,
|
| 59 |
+
gen_kwargs={
|
| 60 |
+
"tsv_path": downloaded["tsv"],
|
| 61 |
+
"audio_root": downloaded["tar"], # now contains audio/pl/…
|
| 62 |
+
},
|
| 63 |
),
|
| 64 |
]
|
| 65 |
|
| 66 |
+
def _generate_examples(self, tsv_path, audio_root):
|
| 67 |
+
# 1) Load the metadata from the TSV
|
|
|
|
| 68 |
meta = {}
|
| 69 |
with open(tsv_path, encoding="utf-8") as f:
|
| 70 |
reader = csv.DictReader(f, delimiter="\t")
|
| 71 |
for row in reader:
|
| 72 |
meta[row["path"]] = row
|
| 73 |
|
| 74 |
+
# 2) Walk the unpacked audio directory
|
| 75 |
key = 0
|
| 76 |
+
pl_root = os.path.join(audio_root, "audio", "pl")
|
| 77 |
+
for speaker in sorted(os.listdir(pl_root)):
|
| 78 |
+
sp_dir = os.path.join(pl_root, speaker)
|
| 79 |
if not os.path.isdir(sp_dir):
|
| 80 |
continue
|
| 81 |
for fname in sorted(os.listdir(sp_dir)):
|
|
|
|
| 84 |
rel_path = os.path.join("audio", "pl", speaker, fname)
|
| 85 |
row = meta.get(rel_path)
|
| 86 |
if row is None:
|
| 87 |
+
# no transcript entry for this file
|
| 88 |
continue
|
| 89 |
yield key, {
|
| 90 |
+
"path": rel_path,
|
| 91 |
+
"audio": os.path.join(sp_dir, fname),
|
| 92 |
+
"sentence": row["sentence"],
|
| 93 |
+
"age": int(row.get("age", -1)),
|
| 94 |
+
"gender": row.get("gender", "unknown") or "unknown",
|
| 95 |
+
"speech_type": row["speech_type"],
|
| 96 |
+
"source": row["source"],
|
| 97 |
}
|
| 98 |
key += 1
|