carlosdanielhernandezmena commited on
Commit
c3189d8
1 Parent(s): 85324a7

Adding the audio files to the repo

Browse files
corpus/files/metadata_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
corpus/files/tars_train.paths ADDED
@@ -0,0 +1 @@
 
 
1
+ corpus/speech/train.tar.gz
corpus/speech/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebb1578e2217731d12167ffd60f6c491b41c8c57902d97a4a9c9effe33187bb8
3
+ size 3238082167
raddromur_asr.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections import defaultdict
2
+ import os
3
+ import json
4
+ import csv
5
+
6
+ import datasets
7
+
8
+ _NAME="raddromur_asr"
9
+ _VERSION="1.0.0"
10
+ _AUDIO_EXTENSIONS=".flac"
11
+
12
+ _DESCRIPTION = """
13
+ The Raddrómur Corpus is intended for the speech recognition field and it is made out of radio podcasts mostly taken from RÚV (ruv.is). Such podcasts were selected because they contained a text script that matches with certain fidelity what is said during the show. After automatic segmentation of the episodes, the transcriptions were inferred using the scripts along with a forced alignment technique.
14
+ """
15
+
16
+ _CITATION = """
17
+ @misc{carlosmenaraddromur2022,
18
+ title={Raddrómur Icelandic Speech 22.09},
19
+ author={Hernández Mena, Carlos Daniel and Hedström, Staffan and Þórhallsdóttir, Ragnheiður and Fong, Judy Y. and Gunnarsson, Þorsteinn Daði and Sigurðardóttir, Helga Svala and Þorsteinsdóttir, Helga Lára and Guðnason, Jón},
20
+ year={2022},
21
+ url={http://hdl.handle.net/20.500.12537/286},
22
+ }
23
+ """
24
+
25
+ _HOMEPAGE = "http://hdl.handle.net/20.500.12537/286"
26
+
27
+ _LICENSE = "CC-BY-4.0, See https://creativecommons.org/licenses/by/4.0/"
28
+
29
+ _BASE_DATA_DIR = "corpus/"
30
+ _METADATA_TRAIN = os.path.join(_BASE_DATA_DIR,"files","metadata_train.tsv")
31
+
32
+ _TARS_TRAIN = os.path.join(_BASE_DATA_DIR,"files","tars_train.paths")
33
+
34
+ class RaddromurAsrConfig(datasets.BuilderConfig):
35
+ """BuilderConfig for Raddrómur Corpus"""
36
+
37
+ def __init__(self, name, **kwargs):
38
+ name=_NAME
39
+ super().__init__(name=name, **kwargs)
40
+
41
+ class RaddromurAsr(datasets.GeneratorBasedBuilder):
42
+ """Raddrómur Icelandic Speech 22.09"""
43
+
44
+ VERSION = datasets.Version(_VERSION)
45
+ BUILDER_CONFIGS = [
46
+ RaddromurAsrConfig(
47
+ name=_NAME,
48
+ version=datasets.Version(_VERSION),
49
+ )
50
+ ]
51
+
52
+ def _info(self):
53
+ features = datasets.Features(
54
+ {
55
+ "audio_id": datasets.Value("string"),
56
+ "audio": datasets.Audio(sampling_rate=16000),
57
+ "podcast_id": datasets.Value("string"),
58
+ "segment_num": datasets.Value("int32"),
59
+ "start_time": datasets.Value("string"),
60
+ "duration": datasets.Value("float32"),
61
+ "mafia_score": datasets.Value("float32"),
62
+ "normalized_text": datasets.Value("string"),
63
+ }
64
+ )
65
+ return datasets.DatasetInfo(
66
+ description=_DESCRIPTION,
67
+ features=features,
68
+ homepage=_HOMEPAGE,
69
+ license=_LICENSE,
70
+ citation=_CITATION,
71
+ )
72
+
73
+ def _split_generators(self, dl_manager):
74
+
75
+ metadata_train=dl_manager.download_and_extract(_METADATA_TRAIN)
76
+
77
+ tars_train=dl_manager.download_and_extract(_TARS_TRAIN)
78
+
79
+ hash_tar_files=defaultdict(dict)
80
+ with open(tars_train,'r') as f:
81
+ hash_tar_files['train']=[path.replace('\n','') for path in f]
82
+
83
+ hash_meta_paths={"train":metadata_train}
84
+ audio_paths = dl_manager.download(hash_tar_files)
85
+
86
+ splits=["train"]
87
+ local_extracted_audio_paths = (
88
+ dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
89
+ {
90
+ split:[None] * len(audio_paths[split]) for split in splits
91
+ }
92
+ )
93
+
94
+ return [
95
+ datasets.SplitGenerator(
96
+ name=datasets.Split.TRAIN,
97
+ gen_kwargs={
98
+ "audio_archives":[dl_manager.iter_archive(archive) for archive in audio_paths["train"]],
99
+ "local_extracted_archives_paths": local_extracted_audio_paths["train"],
100
+ "metadata_paths": hash_meta_paths["train"],
101
+ }
102
+ ),
103
+ ]
104
+
105
+ def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
106
+
107
+ features = ["podcast_id","segment_num","start_time","duration","mafia_score","normalized_text"]
108
+
109
+ with open(metadata_paths) as f:
110
+ metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
111
+
112
+ for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
113
+ for audio_filename, audio_file in audio_archive:
114
+ audio_id = audio_filename.split(os.sep)[-1].split(_AUDIO_EXTENSIONS)[0]
115
+ path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
116
+
117
+ yield audio_id, {
118
+ "audio_id": audio_id,
119
+ **{feature: metadata[audio_id][feature] for feature in features},
120
+ "audio": {"path": path, "bytes": audio_file.read()},
121
+ }