Delete builder.py
Browse files- builder.py +0 -135
builder.py
DELETED
|
@@ -1,135 +0,0 @@
|
|
| 1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 2 |
-
#
|
| 3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
-
# you may not use this file except in compliance with the License.
|
| 5 |
-
# You may obtain a copy of the License at
|
| 6 |
-
#
|
| 7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
-
#
|
| 9 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
-
# See the License for the specific language governing permissions and
|
| 13 |
-
# limitations under the License.
|
| 14 |
-
"""Leading and Trailing Silences Removed Large Nepali ASR Dataset"""
|
| 15 |
-
|
| 16 |
-
import os
|
| 17 |
-
import csv
|
| 18 |
-
|
| 19 |
-
import datasets
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
_CITATION = """\
|
| 23 |
-
@inproceedings{kjartansson-etal-sltu2018,
|
| 24 |
-
title = {{Crowd-Sourced Speech Corpora for Javanese, Sundanese, Sinhala, Nepali, and Bangladeshi Bengali}},
|
| 25 |
-
author = {Oddur Kjartansson and Supheakmungkol Sarin and Knot Pipatsrisawat and Martin Jansche and Linne Ha},
|
| 26 |
-
booktitle = {Proc. The 6th Intl. Workshop on Spoken Language Technologies for Under-Resourced Languages (SLTU)},
|
| 27 |
-
year = {2018},
|
| 28 |
-
address = {Gurugram, India},
|
| 29 |
-
month = aug,
|
| 30 |
-
pages = {52--55},
|
| 31 |
-
URL = {http://dx.doi.org/10.21437/SLTU.2018-11}
|
| 32 |
-
}
|
| 33 |
-
"""
|
| 34 |
-
|
| 35 |
-
_DESCRIPTION = """\
|
| 36 |
-
This data set contains transcribed audio data for Nepali. The data set consists of flac files, and a TSV file. The file utt_spk_text.tsv contains a FileID, anonymized UserID and the transcription of audio in the file.
|
| 37 |
-
The data set has been manually quality checked, but there might still be errors.
|
| 38 |
-
The audio files are sampled at rate of 16KHz, and leading and trailing silences are trimmed using torchaudio's voice activity detection.
|
| 39 |
-
"""
|
| 40 |
-
|
| 41 |
-
# Official homepage for the dataset
|
| 42 |
-
_HOMEPAGE = "https://www.openslr.org/54/"
|
| 43 |
-
|
| 44 |
-
# The licence for the dataset
|
| 45 |
-
_LICENSE = "license:cc-by-sa-4.0"
|
| 46 |
-
|
| 47 |
-
# TODO: Add link to the official dataset URLs here
|
| 48 |
-
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
| 49 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
# _URLS = {
|
| 53 |
-
# 'cleaned': {
|
| 54 |
-
# "index_file": "https://huggingface.co/datasets/spktsagar/openslr-nepali-asr-cleaned/resolve/main/data/utt_spk_text_clean.tsv",
|
| 55 |
-
# "zipfiles": [
|
| 56 |
-
# f"https://huggingface.co/datasets/spktsagar/openslr-nepali-asr-cleaned/resolve/main/data/asr_nepali_{k}.zip"
|
| 57 |
-
# for k in [*range(10), *'abcdef']
|
| 58 |
-
# ],
|
| 59 |
-
# },
|
| 60 |
-
# 'original': {
|
| 61 |
-
# "index_file": "https://huggingface.co/datasets/spktsagar/openslr-nepali-asr-cleaned/resolve/main/data/utt_spk_text_orig.tsv",
|
| 62 |
-
# "zipfiles": [
|
| 63 |
-
# f"https://www.openslr.org/resources/54/asr_nepali_{k}.zip"
|
| 64 |
-
# for k in [*range(10), *'abcdef']
|
| 65 |
-
# ],
|
| 66 |
-
# },
|
| 67 |
-
# }
|
| 68 |
-
_URL = "https://huggingface.co/datasets/SumitMdhr/ASR/resolve/main/"
|
| 69 |
-
_URLS = {
|
| 70 |
-
"zipfile": _URL + "CLEAN_DATA.zip",
|
| 71 |
-
"index_file": _URL + "metedata1.tsv",
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
| 76 |
-
class NepaliAsr(datasets.GeneratorBasedBuilder):
|
| 77 |
-
"""End Silences Removed Large Nepali ASR Dataset"""
|
| 78 |
-
|
| 79 |
-
VERSION = datasets.Version("1.0.0")
|
| 80 |
-
|
| 81 |
-
def _info(self):
|
| 82 |
-
features = datasets.Features(
|
| 83 |
-
{
|
| 84 |
-
"utterance_id": datasets.Value("string"),
|
| 85 |
-
"utterance": datasets.Audio(),
|
| 86 |
-
"transcription": datasets.Value("string"),
|
| 87 |
-
}
|
| 88 |
-
)
|
| 89 |
-
return datasets.DatasetInfo(
|
| 90 |
-
description=_DESCRIPTION,
|
| 91 |
-
# Here we define them above because they are different between the two configurations
|
| 92 |
-
features=features,
|
| 93 |
-
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
| 94 |
-
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
| 95 |
-
# supervised_keys=("sentence", "label"),
|
| 96 |
-
# Homepage of the dataset for documentation
|
| 97 |
-
homepage=_HOMEPAGE,
|
| 98 |
-
# License for the dataset if available
|
| 99 |
-
license=_LICENSE,
|
| 100 |
-
# Citation for the dataset
|
| 101 |
-
citation=_CITATION,
|
| 102 |
-
task_templates=[
|
| 103 |
-
datasets.tasks.AutomaticSpeechRecognition(
|
| 104 |
-
audio_column="utterance", transcription_column="transcription"
|
| 105 |
-
)
|
| 106 |
-
],
|
| 107 |
-
)
|
| 108 |
-
|
| 109 |
-
def _split_generators(self, dl_manager):
|
| 110 |
-
index_file = dl_manager.download(_URLS["index_file"])
|
| 111 |
-
zip_paths = dl_manager.download(_URLS["zipfile"])
|
| 112 |
-
audio_paths = dl_manager.extract(zip_paths)
|
| 113 |
-
for path in zip_paths:
|
| 114 |
-
if os.path.exists(path):
|
| 115 |
-
os.remove(path)
|
| 116 |
-
return [
|
| 117 |
-
datasets.SplitGenerator(
|
| 118 |
-
name=datasets.Split.TRAIN,
|
| 119 |
-
gen_kwargs={
|
| 120 |
-
"index_file": index_file,
|
| 121 |
-
"audio_paths": audio_paths,
|
| 122 |
-
},
|
| 123 |
-
),
|
| 124 |
-
]
|
| 125 |
-
|
| 126 |
-
def _generate_examples(self, index_file, audio_paths):
|
| 127 |
-
with open(index_file, encoding="utf-8") as f:
|
| 128 |
-
reader = csv.DictReader(f , delimiter="\t")
|
| 129 |
-
for key, row in enumerate(reader):
|
| 130 |
-
path = os.path.join(audio_paths, "CLEAN_DATA", row['utterance_id'])
|
| 131 |
-
yield key, {
|
| 132 |
-
"utterance_id": row["utterance_id"],
|
| 133 |
-
"utterance": path,
|
| 134 |
-
"transcription": row["transcription"],
|
| 135 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|