File size: 6,415 Bytes
a27a700 f2e2266 a27a700 f2e2266 a27a700 b2bc413 a27a700 f2e2266 a27a700 11cc927 a27a700 11cc927 0497e1e a27a700 f2e2266 a27a700 11cc927 a27a700 a7464f1 a27a700 c5f4205 a27a700 11cc927 a27a700 7a6e38c ee95f1e a27a700 11cc927 a27a700 11cc927 a27a700 9a39598 4d81832 a27a700 74d4e24 a27a700 f2e2266 a27a700 8458c7e a27a700 ee549b9 a27a700 c5f4205 a27a700 |
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# coding=utf-8
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Elite Voice Project"""
import csv
import os
import json
import datasets
from datasets.utils.py_utils import size_str
from tqdm import tqdm
_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.gz"
_TRANSCRIPT_URL = _BASE_URL + "transcript/{platform}/{split}/{platform}_{split}_{version}.csv"
_PLATFORMS = ["twitter"]
#_PLATFORMS = ["twitter", "youtube", "twitch"]
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=platform,
version='0.0.2',
language='Japanese',
release_date='2022-12-08',
)
for platform in _PLATFORMS
]
DEFAULT_CONFIG_NAME = "twitter"
def _info(self):
description = (
"Elite Voice Project はホロライブ所属VTuberのさくらみこ氏の声をデータセット化することを目的に"
"TwitterのSpace配信等のアーカイブから音声を切り出し、センテンスを当てています。"
"当データセットは、hololive productionの二次創作ガイドラインに沿ってご利用ください。"
)
features = datasets.Features(
{
"path": datasets.Value("string"),
"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):
platform = self.config.name
version = self.config.version
audio_urls = {}
splits = ("train", "test")
#splits = ["train"]
for split in splits:
audio_urls[split] = [
_AUDIO_URL.format(platform=platform, 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=platform, 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, 'rt', newline='', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile)
for row in tqdm(reader, desc="Reading metadata..."):
if not row["path"].endswith(".mp3"):
row["path"] += ".mp3"
# accent -> accents in CV 8.0
#if "accents" in row:
# row["accent"] = row["accents"]
# del row["accents"]
# if data is incomplete, fill with empty values
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])
# set the audio feature and the path to the extracted file
path = os.path.join(local_extracted_archive_paths[i], filename) if local_extracted_archive_paths else filename
result["audio"] = {"path": path, "bytes": file.read()}
# set path to None if the audio file doesn't exist locally (i.e. in streaming mode)
result["path"] = path if local_extracted_archive_paths else filename
yield path, result |