File size: 6,702 Bytes
7a80915 29bc121 7a80915 89be29c 7a80915 89be29c 7a80915 89be29c 7a80915 8f48036 7a80915 1b6b373 7a80915 4fb3fc3 7a80915 29bc121 238d5b8 29bc121 ce4e32f 29bc121 8f48036 29bc121 8f48036 29bc121 |
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 |
# coding=utf-8
# Copyright 2021 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# 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.
# Lint as: python3
"""Libri-Light audio dataset."""
import glob
import os
import json
import datasets
_CITATION = """\
@INPROCEEDINGS{librilight,
author={J. Kahn and M. Rivière and W. Zheng and E. Kharitonov and Q. Xu and P. E. Mazaré and J. Karadayi and V. Liptchinsky and R. Collobert and C. Fuegen and T. Likhomanenko and G. Synnaeve and A. Joulin and A. Mohamed and E. Dupoux},
booktitle={ICASSP 2020 - 2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
title={Libri-Light: A Benchmark for ASR with Limited or No Supervision},
year={2020},
pages={7669-7673},
}
"""
_DESCRIPTION = """\
Libri-light is a large dataset of 60K hours of unlabelled speech from audiobooks in English.
It is a benchmark for the training of automatic speech recognition (ASR) systems with limited or no supervision.
"""
_HOMEPAGE = "https://ai.facebook.com/tools/libri-light/"
_LICENSE = """\
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
_DL_URL = "https://dl.fbaipublicfiles.com/librilight/data/{name}.tar"
class LibriLightConfig(datasets.BuilderConfig):
"""BuilderConfig for Libri-Light."""
def __init__(self, **kwargs):
super(LibriLightConfig, self).__init__(version=datasets.Version("2.1.0", ""), **kwargs)
class LibriLight(datasets.GeneratorBasedBuilder):
"""Libri-Light dataset."""
BUILDER_CONFIGS = [
LibriLightConfig(name="small", description="577 hours, 35 GB."),
LibriLightConfig(name="medium", description="5193 hours, 321 GB."),
LibriLightConfig(name="large", description="51934 hours, 3.05 TB."),
]
def _info(self):
features = datasets.Features(
{
"id": datasets.Value("string"),
"file": datasets.Value("string"),
"audio": datasets.Audio(sampling_rate=16_000),
"speaker_id": datasets.Value("int64"),
"metadata": {
"speaker": datasets.Value("string"),
"book_meta": {
"id": datasets.Value("string"),
"title": datasets.Value("string"),
"description": datasets.Value("string"),
"url_text_source": datasets.Value("string"),
"language": datasets.Value("string"),
"copyright_year": datasets.Value("string"),
"num_sections": datasets.Value("string"),
"url_rss": datasets.Value("string"),
"url_zip_file": datasets.Value("string"),
"url_project": datasets.Value("string"),
"url_librivox": datasets.Value("string"),
"url_other": datasets.Value("string"),
"totaltimesecs": datasets.Value("int64"),
"authors": datasets.Sequence(
{
"id": datasets.Value("string"),
"first_name": datasets.Value("string"),
"last_name": datasets.Value("string"),
"dob": datasets.Value("string"),
"dod": datasets.Value("string")
}
),
"genre": datasets.Sequence(datasets.Value("string")),
"Dramatic Readings": datasets.Value("bool"),
"meta_genre": datasets.Value("string"),
},
"snr": datasets.Value("float32"),
"voice_activity": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
}
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
archive_path = dl_manager.download_and_extract({"train": _DL_URL.format(name=self.config.name)})
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"archive_path": archive_path["train"]},
),
]
def _generate_examples(self, archive_path):
paths = glob.glob(os.path.join(archive_path, self.config.name, "**", "**", "*.flac"))
for key, path in enumerate(paths):
path_split = path.split(os.path.sep)
id_ = path_split[-1].replace(".flac", "")
speaker_id = int(path_split[-3])
path_json = path.replace(".flac", ".json")
with open(path_json) as json_file:
metadata = json.load(json_file)
yield key, {
"id": id_,
"file": path,
"audio": path,
"speaker_id": speaker_id,
"metadata": metadata,
}
|