File size: 4,229 Bytes
7ca387f d6dc076 7ca387f d6dc076 7ca387f d6dc076 7ca387f d6dc076 7ca387f d6dc076 7ca387f d6dc076 7ca387f b421e47 7ca387f 81e4ce3 7ca387f 6fcd760 7ca387f d6dc076 9b20878 b421e47 7ca387f |
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 |
import gzip
import json
import re
import os
import datasets
logger = datasets.logging.get_logger(__name__)
_DESCRIPTION = """\\nThis data set contains multi-speaker high quality transcribed audio data for Sinhala. The data set consists of wave files, and a TSV file.
The file si_lk.lines.txt contains a FileID, which in tern contains the UserID and the Transcription of audio in the file.
The data set has been manually quality checked, but there might still be errors.
Part of this dataset was collected by Google in Sri Lanka and the rest was contributed by Path to Nirvana organization.
"""
_CITATION = """
@inproceedings{Sodimana2018,
author={Keshan Sodimana and Pasindu {De Silva} and Supheakmungkol Sarin and Oddur Kjartansson and Martin Jansche and Knot Pipatsrisawat and Linne Ha},
title={{A Step-by-Step Process for Building TTS Voices Using Open Source Data and Frameworks for Bangla, Javanese, Khmer, Nepali, Sinhala, and Sundanese}},
year=2018,
booktitle={Proc. The 6th Intl. Workshop on Spoken Language Technologies for Under-Resourced Languages},
pages={66--70},
doi={10.21437/SLTU.2018-14},
url={http://dx.doi.org/10.21437/SLTU.2018-14}
}
"""
_URL = "https://www.openslr.org/30/"
_DATA_URL = "https://huggingface.co/datasets/keshan/wit-dataset/resolve/09d263477614f9fa8c8af0d8ad78f6d4e410a43c/data.tar.gz"
_DATA_FILE_URL = "https://huggingface.co/datasets/keshan/wit-dataset/resolve/09d263477614f9fa8c8af0d8ad78f6d4e410a43c/file_index.tsv"
_LICENSE = "https://www.openslr.org/resources/30/LICENSE.txt"
_LANGUAGES = [
"si",
]
class SiTTSConfig(datasets.BuilderConfig):
"""BuilderConfig for SiTTS."""
def __init__(self, *args, **kwargs):
"""BuilderConfig for SiTTS.
Args:
languages (:obj:`List[str]`): list of languages to load
**kwargs: keyword arguments forwarded to super.
"""
super().__init__(
*args, **kwargs,
)
class SiTTS(datasets.GeneratorBasedBuilder):
"""SiTTS, a manually quality checked, Sinhala multi-speaker TTS corpora."""
BUILDER_CONFIGS = [SiTTSConfig(languages=[lang]) for lang in _LANGUAGES]
BUILDER_CONFIG_CLASS = SiTTSConfig
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"id": datasets.Value("string"),
"sentence": datasets.Value("string"),
"file_path": datasets.Value("string"),
}
),
supervised_keys=None,
homepage=_URL,
citation=_CITATION,
license=_LICENSE,
)
def _split_generators(self, dl_manager):
abs_path_to_clips = dl_manager.download_and_extract(_DATA_URL)
abs_path_to_data = dl_manager.download(_DATA_FILE_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filepath": abs_path_to_data,
"path_to_clips": abs_path_to_clips,
},
),
]
def _generate_examples(self, filepath, path_to_clips):
data_fields = list(self._info().features.keys())
path_idx = data_fields.index("file_path")
with open(filepath, encoding="utf-8") as f:
lines = f.readlines()
for id_, line in enumerate(lines):
id_value, sentence = line.strip().split("\t")
# sentence = re.findall(r'"(.*?)"', line)[0].strip()
# id_value = re.findall(r"(sin_[^\s]+)", line)[0]
file_path = "{0}.wav".format(id_value)
field_values = [id_value, sentence, file_path]
# set absolute path for wav audio file
field_values[path_idx] = os.path.join(
path_to_clips, field_values[path_idx]
)
# if data is incomplete, fill with empty values
if len(field_values) < len(data_fields):
field_values += (len(data_fields) - len(field_values)) * ["''"]
yield id_, {key: value for key, value in zip(data_fields, field_values)}
|