|
|
|
"""The MC Speech Dataset""" |
|
|
|
import pathlib |
|
|
|
import datasets |
|
|
|
|
|
_DESCRIPTION = """\ |
|
This is public domain speech dataset consisting of 24018 short audio clips of a single speaker |
|
reading sentences in Polish. A transcription is provided for each clip. Clips have total length of |
|
more than 22 hours. |
|
Texts are in public domain. The audio was recorded in 2021-22 as a part of my master's thesis and |
|
is in public domain. |
|
""" |
|
_HOMEPAGE = "https://github.com/czyzi0/the-mc-speech-dataset" |
|
_CITATION = """\ |
|
@masterthesis{mcspeech, |
|
title={Analiza porównawcza korpusów nagrań mowy dla celów syntezy mowy w języku polskim}, |
|
author={Czyżnikiewicz, Mateusz}, |
|
year={2022}, |
|
month={December}, |
|
school={Warsaw University of Technology}, |
|
type={Master's thesis}, |
|
doi={10.13140/RG.2.2.26293.24800}, |
|
note={Available at \\url{http://dx.doi.org/10.13140/RG.2.2.26293.24800}}, |
|
} |
|
""" |
|
_LICENSE = "CC0 1.0" |
|
|
|
|
|
|
|
class MCSpeech(datasets.GeneratorBasedBuilder): |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"audio": datasets.Audio(sampling_rate=44_100), |
|
"transcript": datasets.Value("string"), |
|
"id": datasets.Value("string"), |
|
}, |
|
), |
|
supervised_keys=None, |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
license=_LICENSE, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
transcripts_path = dl_manager.download_and_extract( |
|
"https://huggingface.co/datasets/czyzi0/the-mc-speech-dataset/raw/main/transcripts.tsv" |
|
) |
|
wavs_path = dl_manager.download_and_extract( |
|
"https://huggingface.co/datasets/czyzi0/the-mc-speech-dataset/resolve/main/wavs.tar.gz" |
|
) |
|
return [ |
|
datasets.SplitGenerator( |
|
name="train", |
|
gen_kwargs={"transcripts_path": transcripts_path, "wavs_path": wavs_path} |
|
) |
|
] |
|
|
|
def _generate_examples(self, transcripts_path, wavs_path): |
|
wavs_path = pathlib.Path(wavs_path) |
|
with open(transcripts_path, "r") as fh: |
|
header = next(fh).strip().split("\t") |
|
for item_idx, line in enumerate(fh): |
|
line = line.strip().split("\t") |
|
id_ = line[header.index("id")] |
|
transcript = line[header.index("transcript")] |
|
|
|
wav_path = wavs_path / "wavs" / f"{id_}.wav" |
|
with open(wav_path, "rb") as fh_: |
|
item = { |
|
"audio": {"path": str(wav_path.absolute()), "bytes": fh_.read()}, |
|
"transcript": transcript, |
|
"id": id_, |
|
} |
|
yield item_idx, item |
|
|