holylovenia
commited on
Commit
•
999d809
1
Parent(s):
2c2c08f
Upload oil.py with huggingface_hub
Browse files
oil.py
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
from pathlib import Path
|
17 |
+
from typing import Dict, List, Tuple
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
import pandas as pd
|
21 |
+
|
22 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
23 |
+
from seacrowd.utils.constants import TASK_TO_SCHEMA, Licenses
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
@inproceedings{maxwelll-smith-foley-2023-automated,
|
27 |
+
title = "Automated speech recognition of {I}ndonesian-{E}nglish language lessons on {Y}ou{T}ube using transfer learning",
|
28 |
+
author = "Maxwell-Smith, Zara and Foley, Ben",
|
29 |
+
editor = "Serikov, Oleg
|
30 |
+
and Voloshina, Ekaterina
|
31 |
+
and Postnikova, Anna
|
32 |
+
and Klyachko, Elena
|
33 |
+
and Vylomova, Ekaterina
|
34 |
+
and Shavrina, Tatiana
|
35 |
+
and Le Ferrand, Eric
|
36 |
+
and Malykh, Valentin
|
37 |
+
and Tyers, Francis
|
38 |
+
and Arkhangelskiy, Timofey
|
39 |
+
and Mikhailov, Vladislav",
|
40 |
+
booktitle = "Proceedings of the Second Workshop on NLP Applications to Field Linguistics",
|
41 |
+
month = may,
|
42 |
+
year = "2023",
|
43 |
+
address = "Dubrovnik, Croatia",
|
44 |
+
publisher = "Association for Computational Linguistics",
|
45 |
+
url = "https://aclanthology.org/2023.fieldmatters-1.1",
|
46 |
+
doi = "10.18653/v1/2023.fieldmatters-1.1",
|
47 |
+
pages = "1--16",
|
48 |
+
abstract = "Experiments to fine-tune large multilingual models with limited data from a specific domain or setting has potential
|
49 |
+
to improve automatic speech recognition (ASR) outcomes. This paper reports on the use of the Elpis ASR pipeline to fine-tune two
|
50 |
+
pre-trained base models, Wav2Vec2-XLSR-53 and Wav2Vec2-Large-XLSR-Indonesian, with various mixes of data from 3 YouTube channels
|
51 |
+
teaching Indonesian with English as the language of instruction. We discuss our results inferring new lesson audio (22-46%
|
52 |
+
word error rate) in the context of speeding data collection in diverse and specialised settings. This study is an example of how
|
53 |
+
ASR can be used to accelerate natural language research, expanding ethically sourced data in low-resource settings.",
|
54 |
+
}
|
55 |
+
"""
|
56 |
+
|
57 |
+
_DATASETNAME = "oil"
|
58 |
+
|
59 |
+
_DESCRIPTION = """\
|
60 |
+
The Online Indonesian Learning (OIL) dataset or corpus currently contains lessons from three Indonesian teachers who have posted content on YouTube.
|
61 |
+
"""
|
62 |
+
|
63 |
+
_HOMEPAGE = "https://huggingface.co/datasets/ZMaxwell-Smith/OIL"
|
64 |
+
|
65 |
+
_LANGUAGES = ["eng", "ind"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
|
66 |
+
|
67 |
+
_LICENSE = Licenses.CC_BY_NC_ND_4_0.value
|
68 |
+
|
69 |
+
_LOCAL = False
|
70 |
+
|
71 |
+
_URLS = {
|
72 |
+
_DATASETNAME: {"train": "https://huggingface.co/api/datasets/ZMaxwell-Smith/OIL/parquet/default/train/0.parquet"},
|
73 |
+
}
|
74 |
+
|
75 |
+
_SUPPORTED_TASKS = []
|
76 |
+
_SUPPORTED_SCHEMA_STRINGS = [f"seacrowd_{str(TASK_TO_SCHEMA[task]).lower()}" for task in _SUPPORTED_TASKS]
|
77 |
+
|
78 |
+
_SOURCE_VERSION = "1.0.0"
|
79 |
+
|
80 |
+
_SEACROWD_VERSION = "2024.06.20"
|
81 |
+
|
82 |
+
|
83 |
+
class OIL(datasets.GeneratorBasedBuilder):
|
84 |
+
"""The Online Indonesian Learning (OIL) dataset or corpus currently contains lessons from three Indonesian teachers who have posted content on YouTube."""
|
85 |
+
|
86 |
+
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
87 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
88 |
+
|
89 |
+
BUILDER_CONFIGS = [
|
90 |
+
SEACrowdConfig(
|
91 |
+
name=f"{_DATASETNAME}_source",
|
92 |
+
version=SOURCE_VERSION,
|
93 |
+
description=f"{_DATASETNAME} source schema",
|
94 |
+
schema="source",
|
95 |
+
subset_id=f"{_DATASETNAME}",
|
96 |
+
),
|
97 |
+
]
|
98 |
+
|
99 |
+
DEFAULT_CONFIG_NAME = f"{_DATASETNAME}_source"
|
100 |
+
|
101 |
+
def _info(self) -> datasets.DatasetInfo:
|
102 |
+
|
103 |
+
if self.config.schema == "source":
|
104 |
+
features = datasets.Features(
|
105 |
+
{
|
106 |
+
"audio": datasets.Audio(decode=False),
|
107 |
+
"label": datasets.ClassLabel(num_classes=98),
|
108 |
+
}
|
109 |
+
)
|
110 |
+
|
111 |
+
else:
|
112 |
+
raise ValueError(f"Invalid config: {self.config.name}")
|
113 |
+
|
114 |
+
return datasets.DatasetInfo(
|
115 |
+
description=_DESCRIPTION,
|
116 |
+
features=features,
|
117 |
+
homepage=_HOMEPAGE,
|
118 |
+
license=_LICENSE,
|
119 |
+
citation=_CITATION,
|
120 |
+
)
|
121 |
+
|
122 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
123 |
+
"""Returns SplitGenerators."""
|
124 |
+
|
125 |
+
urls = _URLS[_DATASETNAME]
|
126 |
+
train_path = dl_manager.download_and_extract(urls["train"])
|
127 |
+
|
128 |
+
return [
|
129 |
+
datasets.SplitGenerator(
|
130 |
+
name=datasets.Split.TRAIN,
|
131 |
+
gen_kwargs={
|
132 |
+
"filepath": train_path,
|
133 |
+
"split": "train",
|
134 |
+
},
|
135 |
+
),
|
136 |
+
]
|
137 |
+
|
138 |
+
def _generate_examples(self, filepath: Path, split: str) -> Tuple[int, Dict]:
|
139 |
+
"""Yields examples as (key, example) tuples."""
|
140 |
+
|
141 |
+
if self.config.schema == "source":
|
142 |
+
|
143 |
+
df = pd.read_parquet(filepath)
|
144 |
+
|
145 |
+
for index, row in df.iterrows():
|
146 |
+
yield index, row.to_dict()
|
147 |
+
|
148 |
+
else:
|
149 |
+
raise ValueError(f"Invalid config: {self.config.name}")
|