Datasets:
File size: 2,841 Bytes
1daf7b9 a417c84 1daf7b9 1fdfd9e 1daf7b9 9208b42 1daf7b9 9208b42 1daf7b9 a417c84 1daf7b9 a417c84 1daf7b9 a417c84 1daf7b9 a417c84 9208b42 |
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 |
# coding=utf-8
"""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
|