Datasets:
Size:
10K<n<100K
ArXiv:
File size: 3,985 Bytes
b5824c6 96a54e3 b5824c6 a4d6d07 b5824c6 96a54e3 b5824c6 96a54e3 b5824c6 96a54e3 b5824c6 96a54e3 b5824c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
from pathlib import Path
import datasets
from datasets import (
Features,
SplitGenerator,
)
import pandas as pd
DATA_ARCHIVE = "data.zip"
TABLE_ARCHIVE = "tables.zip"
NAMES = [
"all",
"asm",
"bgc",
"bht",
"ckb",
"eng",
"ewe",
"fra",
"guj",
"ibo",
"kan",
"lin",
"luo",
"mal",
"mar",
"nag",
"nde",
"nlx",
"pan",
"peg",
"rus",
"tam",
"tel",
"tw-akuapem",
"tw-asante",
"ukr",
"urd",
"vie",
"yor",
]
DESCRIPTION = ""
CITATION = "TODO"
HOMPAGE = "github.com/LennartKeller"
class SpeechTaxiConfig(datasets.BuilderConfig):
def __init__(
self, name, description, citation, homepage
):
super().__init__(
name=name,
version=datasets.Version("0.0.1"),
description=description,
)
self.name = name
self.description = description
self.citation = citation
self.homepage = homepage
def get_config(name):
return SpeechTaxiConfig(name=name, description=DESCRIPTION, citation=CITATION, homepage=HOMPAGE)
class SpeechTaxi(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [get_config(name) for name in NAMES]
BUILDER_CONFIG_CLASS = SpeechTaxiConfig
def _info(self):
return datasets.DatasetInfo(
description=DESCRIPTION,
features=Features(
{
"verse_ref": datasets.features.Value("string"),
"text_en": datasets.features.Value("string"),
"language": datasets.features.Value("string"),
"transcription": datasets.features.Value("string"),
"transcription_romanized": datasets.features.Value("string"),
"label": datasets.features.ClassLabel(
names=[
"Recommendation",
"Faith",
"Description",
"Sin",
"Grace",
"Violence",
]
),
"audio": datasets.features.Audio(sampling_rate=16_000),
"transription_mms-zeroshot-300m": datasets.features.Value("string"),
"transription_mms": datasets.features.Value("string"),
"transription_whisper-large-v3": datasets.features.Value("string"),
}
),
supervised_keys=None,
homepage=HOMPAGE,
citation=CITATION,
)
def _split_generators(self, dl_manager):
table_dir = dl_manager.download_and_extract(TABLE_ARCHIVE)
# Make sure data is downloaded
data_dir = dl_manager.download_and_extract(DATA_ARCHIVE)
return [
SplitGenerator(name="train", gen_kwargs={"split": "train", "table_dir": table_dir, "data_dir": data_dir}),
SplitGenerator(name="test", gen_kwargs={"split": "test", "table_dir": table_dir, "data_dir": data_dir}),
SplitGenerator(name="dev", gen_kwargs={"split": "dev", "table_dir": table_dir, "data_dir": data_dir}),
# Add more splits as necessary
]
def _generate_examples(self, split, table_dir, data_dir):
table_dir = Path(table_dir)
data_dir = Path(data_dir)
idx = 0
if self.config.name != "all":
table_files = [table_dir / f"{self.config.name}.tsv"]
else:
table_files = sorted(table_dir.glob("*.tsv"))
for table_file in table_files:
# Load the table
df = pd.read_table(table_file)
df["language"] = table_file.stem
df = df.query("split == @split").reset_index(drop=True)
for _, row in df.iterrows():
row["audio"] = str(data_dir / row["audio"])
yield idx, row.to_dict()
idx += 1
|