|
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") |
|
|
|
|
|
file_path = "{0}.wav".format(id_value) |
|
field_values = [id_value, sentence, file_path] |
|
|
|
|
|
field_values[path_idx] = os.path.join( |
|
path_to_clips, field_values[path_idx] |
|
) |
|
|
|
|
|
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)} |
|
|