|
"""LibriS2S dataset.""" |
|
|
|
import csv |
|
import os |
|
from typing import Dict, List, Tuple |
|
|
|
import datasets |
|
|
|
|
|
_CITATION = """@inproceedings{jeuris-niehues-2022-libris2s, |
|
title = "{L}ibri{S}2{S}: A {G}erman-{E}nglish Speech-to-Speech Translation Corpus", |
|
author = "Jeuris, Pedro and Niehues, Jan", |
|
booktitle = "Proceedings of the Thirteenth Language Resources and Evaluation Conference", |
|
year = "2022", |
|
url = "https://aclanthology.org/2022.lrec-1.98", |
|
pages = "928--935" |
|
}""" |
|
|
|
_DESCRIPTION = """LibriS2S: A German-English Speech-to-Speech Translation Corpus""" |
|
|
|
_HOMEPAGE = "https://huggingface.co/datasets/PedroDKE/LibriS2S" |
|
|
|
_LICENSE = "cc-by-nc-sa-4.0" |
|
|
|
|
|
class LibriS2S(datasets.GeneratorBasedBuilder): |
|
"""LibriS2S dataset.""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
def _info(self) -> datasets.DatasetInfo: |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"book_id": datasets.Value("int64"), |
|
"DE_audio": datasets.Audio(), |
|
"EN_audio": datasets.Audio(), |
|
"score": datasets.Value("float32"), |
|
"DE_transcript": datasets.Value("string"), |
|
"EN_transcript": datasets.Value("string"), |
|
} |
|
), |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: |
|
"""Returns SplitGenerators.""" |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"split": "train", |
|
"data_dir": ".", |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, split: str, data_dir: str) -> Tuple[int, Dict]: |
|
"""Yields examples.""" |
|
csv_path = os.path.join(data_dir, "alignments", "all_de_en_alligned_cleaned.csv") |
|
|
|
with open(csv_path, encoding="utf-8") as f: |
|
reader = csv.DictReader(f) |
|
for idx, row in enumerate(reader): |
|
|
|
de_audio_path = os.path.join(data_dir, row["DE_audio"]) |
|
en_audio_path = os.path.join(data_dir, row["EN_audio"]) |
|
|
|
yield idx, { |
|
"book_id": int(row["book_id"]), |
|
"DE_audio": de_audio_path, |
|
"EN_audio": en_audio_path, |
|
"score": float(row["score"]), |
|
"DE_transcript": row["DE_transcript"], |
|
"EN_transcript": row["EN_transcript"], |
|
} |