|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Elite Voice Project""" |
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
_CITATION = """\ |
|
@InProceedings{elitevoiceproject:dataset, |
|
title = {Elite Voice Project}, |
|
author={Elite35P Server.}, |
|
year={2022} |
|
} |
|
""" |
|
|
|
_HOMEPAGE = "https://nyahello.jp/" |
|
|
|
_LICENSE = "https://hololive.hololivepro.com/guidelines/" |
|
|
|
_BASE_URL = "https://huggingface.co/datasets/Elite35P-Server/EliteVoiceProject/resolve/main/" |
|
|
|
_AUDIO_URL = _BASE_URL + "audio/{platform}/{split}/{platform}_{split}_{version}.tar" |
|
|
|
_TRANSCRIPT_URL = _BASE_URL + "transcript/{platform}/{split}/{platform}_{split}_{version}.tsv" |
|
|
|
|
|
class EliteVoiceProjectConfig(datasets.BuilderConfig): |
|
"""BuilderConfig for EliteVoiceProject.""" |
|
|
|
def __init__(self, name, version, **kwargs): |
|
self.language = kwargs.pop("language", None) |
|
self.release_date = kwargs.pop("release_date", None) |
|
description = ( |
|
f"Elite Voice Project speech to text dataset in {self.language} released on {self.release_date}. " |
|
) |
|
super(EliteVoiceProjectConfig, self).__init__( |
|
name=name, |
|
version=datasets.Version(version), |
|
description=description, |
|
**kwargs, |
|
) |
|
|
|
|
|
class EliteVoiceProject(datasets.GeneratorBasedBuilder): |
|
DEFAULT_WRITER_BATCH_SIZE = 1000 |
|
|
|
BUILDER_CONFIGS = [ |
|
EliteVoiceProjectConfig( |
|
name=platporm, |
|
version='0.0.1', |
|
language='Japanese', |
|
release_date='2022-12-06', |
|
) |
|
for platporm in ["twitter", "youtube", "youtube"] |
|
] |
|
|
|
def _info(self): |
|
description = ( |
|
"Elite Voice Project はホロライブ所属VTuberのさくらみこ氏の声をデータセット化することを目的に" |
|
"TwitterのSpace配信等のアーカイブから音声を切り出し、センテンスを当てています。" |
|
"当データセットは、hololive productionの二次創作ガイドラインに沿ってご利用ください。" |
|
) |
|
features = datasets.Features( |
|
{ |
|
"audio": datasets.features.Audio(sampling_rate=48_000), |
|
"sentence": datasets.Value("string"), |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=description, |
|
features=features, |
|
supervised_keys=None, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
version=self.config.version, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
platporm = self.config.name |
|
version = self.config.version |
|
|
|
audio_urls = {} |
|
|
|
splits = {"train", "test"} |
|
for split in splits: |
|
audio_urls[split] = [ |
|
_AUDIO_URL.format(platform=platporm, split=split, version=version) |
|
] |
|
archive_paths = dl_manager.download(audio_urls) |
|
local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {} |
|
|
|
meta_urls = {split: _TRANSCRIPT_URL.format(platform=platporm, split=split, version=version) for split in splits} |
|
meta_paths = dl_manager.download_and_extract(meta_urls) |
|
|
|
split_generators = [] |
|
split_names = { |
|
"train": datasets.Split.TRAIN, |
|
"test": datasets.Split.TEST, |
|
} |
|
for split in splits: |
|
split_generators.append( |
|
datasets.SplitGenerator( |
|
name=split_names.get(split, split), |
|
gen_kwargs={ |
|
"local_extracted_archive_paths": local_extracted_archive_paths.get(split), |
|
"archives": [dl_manager.iter_archive(path) for path in archive_paths.get(split)], |
|
"meta_path": meta_paths[split], |
|
}, |
|
), |
|
) |
|
|
|
return split_generators |
|
|
|
def _generate_examples(self, local_extracted_archive_paths, archives, meta_path): |
|
data_fields = list(self._info().features.keys()) |
|
metadata = {} |
|
with open(meta_path, encoding="utf-8") as f: |
|
reader = csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE) |
|
for row in tqdm(reader, desc="Reading metadata..."): |
|
if not row["path"].endswith(".mp3"): |
|
row["path"] += ".mp3" |
|
|
|
if "accents" in row: |
|
row["accent"] = row["accents"] |
|
del row["accents"] |
|
|
|
for field in data_fields: |
|
if field not in row: |
|
row[field] = "" |
|
metadata[row["path"]] = row |
|
|
|
for i, audio_archive in enumerate(archives): |
|
for filename, file in audio_archive: |
|
_, filename = os.path.split(filename) |
|
if filename in metadata: |
|
result = dict(metadata[filename]) |
|
|
|
path = os.path.join(local_extracted_archive_paths[i], filename) if local_extracted_archive_paths else filename |
|
result["audio"] = {"path": path, "bytes": file.read()} |
|
|
|
result["path"] = path if local_extracted_archive_paths else filename |
|
|
|
yield path, result |