PedroDKE commited on
Commit
48b28fd
·
1 Parent(s): da1040a

update dataset

Browse files
PedroDKE--LibriS2S/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """LibriS2S dataset."""
PedroDKE--LibriS2S/libris2s.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """LibriS2S dataset."""
2
+
3
+ import csv
4
+ import os
5
+ from typing import Dict, List, Tuple
6
+
7
+ import datasets
8
+
9
+
10
+ _CITATION = """@inproceedings{jeuris-niehues-2022-libris2s,
11
+ title = "{L}ibri{S}2{S}: A {G}erman-{E}nglish Speech-to-Speech Translation Corpus",
12
+ author = "Jeuris, Pedro and Niehues, Jan",
13
+ booktitle = "Proceedings of the Thirteenth Language Resources and Evaluation Conference",
14
+ year = "2022",
15
+ url = "https://aclanthology.org/2022.lrec-1.98",
16
+ pages = "928--935"
17
+ }"""
18
+
19
+ _DESCRIPTION = """LibriS2S: A German-English Speech-to-Speech Translation Corpus"""
20
+
21
+ _HOMEPAGE = "https://huggingface.co/datasets/PedroDKE/LibriS2S"
22
+
23
+ _LICENSE = "cc-by-nc-sa-4.0"
24
+
25
+
26
+ class LibriS2S(datasets.GeneratorBasedBuilder):
27
+ """LibriS2S dataset."""
28
+
29
+ VERSION = datasets.Version("1.0.0")
30
+
31
+ def _info(self) -> datasets.DatasetInfo:
32
+ return datasets.DatasetInfo(
33
+ description=_DESCRIPTION,
34
+ features=datasets.Features(
35
+ {
36
+ "book_id": datasets.Value("int64"),
37
+ "DE_audio": datasets.Audio(),
38
+ "EN_audio": datasets.Audio(),
39
+ "score": datasets.Value("float32"),
40
+ "DE_transcript": datasets.Value("string"),
41
+ "EN_transcript": datasets.Value("string"),
42
+ }
43
+ ),
44
+ homepage=_HOMEPAGE,
45
+ license=_LICENSE,
46
+ citation=_CITATION,
47
+ )
48
+
49
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
50
+ """Returns SplitGenerators."""
51
+ return [
52
+ datasets.SplitGenerator(
53
+ name=datasets.Split.TRAIN,
54
+ gen_kwargs={
55
+ "split": "train",
56
+ "data_dir": ".",
57
+ },
58
+ ),
59
+ ]
60
+
61
+ def _generate_examples(self, split: str, data_dir: str) -> Tuple[int, Dict]:
62
+ """Yields examples."""
63
+ csv_path = os.path.join(data_dir, "alignments", "all_de_en_alligned_cleaned.csv")
64
+
65
+ with open(csv_path, encoding="utf-8") as f:
66
+ reader = csv.DictReader(f)
67
+ for idx, row in enumerate(reader):
68
+ # Handle paths for both DE and EN audio
69
+ de_audio_path = os.path.join(data_dir, row["DE_audio"])
70
+ en_audio_path = os.path.join(data_dir, row["EN_audio"])
71
+
72
+ yield idx, {
73
+ "book_id": int(row["book_id"]),
74
+ "DE_audio": de_audio_path,
75
+ "EN_audio": en_audio_path,
76
+ "score": float(row["score"]),
77
+ "DE_transcript": row["DE_transcript"],
78
+ "EN_transcript": row["EN_transcript"],
79
+ }
libris2s.py DELETED
@@ -1,71 +0,0 @@
1
- import csv
2
- import os
3
- from datasets import DatasetInfo, GeneratorBasedBuilder, SplitGenerator, Split, Features, Value, Audio
4
-
5
-
6
- class LibriS2SDataset(GeneratorBasedBuilder):
7
- """LibriS2S: A German-English Speech-to-Speech Translation Corpus"""
8
-
9
- VERSION = "1.0.0"
10
- BUILDER_CONFIGS = [
11
- {
12
- "name": "default",
13
- "version": VERSION,
14
- "description": "Default configuration for LibriS2S dataset",
15
- }
16
- ]
17
-
18
- def _info(self):
19
- return DatasetInfo(
20
- description="LibriS2S: A German-English Speech-to-Speech Translation Corpus",
21
- features=Features({
22
- "book_id": Value("int64"),
23
- "DE_audio": Audio(),
24
- "EN_audio": Audio(),
25
- "score": Value("float32"),
26
- "DE_transcript": Value("string"),
27
- "EN_transcript": Value("string"),
28
- }),
29
- homepage="https://huggingface.co/datasets/PedroDKE/LibriS2S",
30
- citation="""@inproceedings{jeuris-niehues-2022-libris2s,
31
- title = "{L}ibri{S}2{S}: A {G}erman-{E}nglish Speech-to-Speech Translation Corpus",
32
- author = "Jeuris, Pedro and Niehues, Jan",
33
- booktitle = "Proceedings of the Thirteenth Language Resources and Evaluation Conference",
34
- year = "2022",
35
- url = "https://aclanthology.org/2022.lrec-1.98",
36
- pages = "928--935"
37
- }""",
38
- license="cc-by-nc-sa-4.0",
39
- )
40
-
41
- def _split_generators(self, dl_manager):
42
- """Returns SplitGenerators."""
43
- return [
44
- SplitGenerator(
45
- name=Split.TRAIN,
46
- gen_kwargs={
47
- "split": "train",
48
- "cache_dir": dl_manager.manual_dir if dl_manager.manual_dir else ".",
49
- }
50
- ),
51
- ]
52
-
53
- def _generate_examples(self, split, cache_dir):
54
- """Yields examples."""
55
- csv_path = os.path.join(cache_dir, "alignments/all_de_en_alligned_cleaned.csv")
56
-
57
- with open(csv_path, encoding="utf-8") as f:
58
- reader = csv.DictReader(f)
59
- for idx, row in enumerate(reader):
60
- # Handle paths for both DE and EN audio
61
- de_audio_path = os.path.join(cache_dir, row["DE_audio"])
62
- en_audio_path = os.path.join(cache_dir, row["EN_audio"])
63
-
64
- yield idx, {
65
- "book_id": int(row["book_id"]),
66
- "DE_audio": de_audio_path,
67
- "EN_audio": en_audio_path,
68
- "score": float(row["score"]),
69
- "DE_transcript": row["DE_transcript"],
70
- "EN_transcript": row["EN_transcript"],
71
- }