Datasets:
Upload vivoice34.py with huggingface_hub
Browse files- vivoice34.py +74 -0
vivoice34.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import datasets
|
| 5 |
+
|
| 6 |
+
_DESCRIPTION = """
|
| 7 |
+
ViVoice-34 preview dataset with Vietnamese speech samples.
|
| 8 |
+
""".strip()
|
| 9 |
+
|
| 10 |
+
_CITATION = """
|
| 11 |
+
@dataset{vivoice34_2026,
|
| 12 |
+
title={ViVoice-34: Vietnamese Speech Dataset from 34 Provinces},
|
| 13 |
+
year={2026},
|
| 14 |
+
url={https://huggingface.co/datasets/anonymous-vivoice34/ViVoice34}
|
| 15 |
+
}
|
| 16 |
+
""".strip()
|
| 17 |
+
|
| 18 |
+
_DATA_DIR = "data/train"
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class ViVoice34(datasets.GeneratorBasedBuilder):
|
| 22 |
+
VERSION = datasets.Version("1.0.0")
|
| 23 |
+
|
| 24 |
+
def _info(self):
|
| 25 |
+
features = datasets.Features(
|
| 26 |
+
{
|
| 27 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
| 28 |
+
"file_name": datasets.Value("string"),
|
| 29 |
+
"transcript": datasets.Value("string"),
|
| 30 |
+
"speaker_id": datasets.Value("string"),
|
| 31 |
+
"province": datasets.Value("string"),
|
| 32 |
+
"gender": datasets.Value("string"),
|
| 33 |
+
"age_group": datasets.Value("string"),
|
| 34 |
+
"duration_s": datasets.Value("float32"),
|
| 35 |
+
"total_word": datasets.Value("int32"),
|
| 36 |
+
"province_code": datasets.Value("string"),
|
| 37 |
+
}
|
| 38 |
+
)
|
| 39 |
+
return datasets.DatasetInfo(
|
| 40 |
+
description=_DESCRIPTION,
|
| 41 |
+
citation=_CITATION,
|
| 42 |
+
features=features,
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
def _split_generators(self, dl_manager):
|
| 46 |
+
train_dir = dl_manager.download_and_extract(_DATA_DIR)
|
| 47 |
+
return [
|
| 48 |
+
datasets.SplitGenerator(
|
| 49 |
+
name=datasets.Split.TRAIN,
|
| 50 |
+
gen_kwargs={"data_dir": train_dir},
|
| 51 |
+
)
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
def _generate_examples(self, data_dir):
|
| 55 |
+
metadata_path = os.path.join(data_dir, "metadata.csv")
|
| 56 |
+
with open(metadata_path, "r", encoding="utf-8", newline="") as handle:
|
| 57 |
+
reader = csv.DictReader(handle)
|
| 58 |
+
for idx, row in enumerate(reader):
|
| 59 |
+
file_name = row.get("file_name", "")
|
| 60 |
+
audio_path = os.path.join(data_dir, file_name)
|
| 61 |
+
duration = float(row.get("duration_s") or 0.0)
|
| 62 |
+
total_word = int(row.get("total_word") or 0)
|
| 63 |
+
yield idx, {
|
| 64 |
+
"audio": audio_path,
|
| 65 |
+
"file_name": file_name,
|
| 66 |
+
"transcript": row.get("transcript", ""),
|
| 67 |
+
"speaker_id": row.get("speaker_id", ""),
|
| 68 |
+
"province": row.get("province", ""),
|
| 69 |
+
"gender": row.get("gender", ""),
|
| 70 |
+
"age_group": row.get("age_group", ""),
|
| 71 |
+
"duration_s": duration,
|
| 72 |
+
"total_word": total_word,
|
| 73 |
+
"province_code": row.get("province_code", ""),
|
| 74 |
+
}
|