Datasets:
File size: 5,968 Bytes
ec12f52 45d0ea7 ec12f52 39fc952 ec12f52 58cb7b6 ec12f52 58cb7b6 ec12f52 58cb7b6 ec12f52 58cb7b6 e6bb6de 58cb7b6 ec12f52 878fae4 cf48bc4 e4147e9 cf48bc4 e4147e9 cf48bc4 e4147e9 cf48bc4 e4147e9 cf48bc4 e4147e9 cf48bc4 |
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# coding=utf-8
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
"""TibetanVoice: The Stanford Question Answering Dataset."""
import csv
import os
import datasets
from datasets.tasks import QuestionAnsweringExtractive
logger = datasets.logging.get_logger(__name__)
_CITATION = """\
@article{2016arXiv160605250R,
author = {spsithar} and {TenzinGayche},
title = "TibetanVoice: 6.5 hours of validated transcribed speech data from 9 audio book in lhasa dialect ",
journal = {arXiv e-prints},
year = 2023,
}
"""
_DESCRIPTION = """\
TibetanVoice: 6.5 hours of validated transcribed speech data from 9 audio book in lhasa dialect. The dataset is in tsv format with two columns, path and sentence. The path column contains the path to the audio file and the sentence column contains the corresponding sentence spoken in the audio file.
"""
_URL = "https://huggingface.co/datasets/openpecha/tibetan_voice/resolve/main/transcripts%20/"
_DataUrl="https://huggingface.co/datasets/openpecha/tibetan_voice/resolve/main/audio/wav.tar"
_URLS = {
"train": _URL + "train-uni.tsv",
"valid": _URL + "valid-uni.tsv",
"test": _URL + "test-uni.tsv",
"train-wylie": _URL + "train-wylie.tsv",
"valid-wylie": _URL + "valid-wylie.tsv",
"test-wylie": _URL + "test-wylie.tsv",
}
class TibetanVoiceConfig(datasets.BuilderConfig):
"""BuilderConfig for TibetanVoice."""
def __init__(self, **kwargs):
"""BuilderConfig for TibetanVoice.
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(TibetanVoiceConfig, self).__init__(**kwargs)
class TibetanVoice(datasets.GeneratorBasedBuilder):
"""TibetanVoice: The Stanford Question Answering Dataset. Version 1.1."""
BUILDER_CONFIGS = [
TibetanVoiceConfig(
name="lhasa",
version=datasets.Version("1.0.0", ""),
description="The dataset comprises 6.5 hours of validated transcribed speech data from 9 audio book in lhasa dialect ",
),
TibetanVoiceConfig(
name="lhasa-wylie",
version=datasets.Version("1.0.0", ""),
description="The dataset comprises 6.5 hours of validated transcribed speech data (wylie) from 9 audio book in lhasa dialect ",
),
]
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"path": datasets.Value("string"),
"audio": datasets.features.Audio(sampling_rate=16_000),
"sentence": datasets.Value("string"),
}
),
# No default supervised_keys (as we have to pass both question
# and context as input).
supervised_keys=None,
homepage="https://huggingface.co/datasets/openpecha/tibetan_voice/",
citation=_CITATION,
)
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download_and_extract(_URLS)
downloaded_wav = dl_manager.download(_DataUrl)
wavs= dl_manager.iter_archive(downloaded_wav)
downloaded_wav = dl_manager.download_and_extract(_DataUrl)
if(self.config.name!='lhasa'):
downloaded_files['train']= downloaded_files['train-wylie']
downloaded_files['test']= downloaded_files['test-wylie']
downloaded_files['valid']= downloaded_files['valid-wylie']
else:
downloaded_files['train']=downloaded_files['train']
downloaded_files['test']= downloaded_files['test']
downloaded_files['valid']= downloaded_files['valid']
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"],"wavs":wavs,'wavfilepath':downloaded_wav}),
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["valid"],"wavs":wavs,'wavfilepath':downloaded_wav}),
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"],"wavs":wavs,'wavfilepath':downloaded_wav}),
]
def _generate_examples(self, filepath, wavs,wavfilepath):
"""This function returns the examples in the raw (text) form."""
example_map = {}
logger.info("generating examples from = %s", filepath)
with open(filepath, encoding="utf-8") as f:
reader = csv.reader(f, delimiter='\t')
for row in reader:
if len(row) >= 2:
path = row[1]
sentence = row[2]
if(str(path)!='path'):
example_map[path] = sentence
else :
continue
audio_map = {}
for path, f in wavs:
_, filename = os.path.split(path)
audio_map[filename] = {"path":os.path.join( wavfilepath,path), "bytes": f.read()}
for key, path in enumerate(example_map.keys()):
filename = path
sentence = example_map.get(filename, "")
audio = audio_map.get(filename, {})
example = {
"path": path,
"sentence": sentence,
"audio": audio
}
yield key, example
|