kfajdsl commited on
Commit
773f117
·
verified ·
1 Parent(s): 9e78df9

Delete loading script

Browse files
Files changed (1) hide show
  1. ami.py +0 -411
ami.py DELETED
@@ -1,411 +0,0 @@
1
- # Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """
15
- The AMI Meeting Corpus consists of 100 hours of meeting recordings. The recordings use a range of signals
16
- synchronized to a common timeline. These include close-talking and far-field microphones, individual and
17
- room-view video cameras, and output from a slide projector and an electronic whiteboard. During the meetings,
18
- the participants also have unsynchronized pens available to them that record what is written. The meetings
19
- were recorded in English using three different rooms with different acoustic properties, and include mostly
20
- non-native speakers.
21
- """
22
-
23
- import os
24
-
25
- import datasets
26
-
27
- _CITATION = """\
28
- @inproceedings{10.1007/11677482_3,
29
- author = {Carletta, Jean and Ashby, Simone and Bourban, Sebastien and Flynn, Mike and Guillemot, Mael and Hain, Thomas and Kadlec, Jaroslav and Karaiskos, Vasilis and Kraaij, Wessel and Kronenthal, Melissa and Lathoud, Guillaume and Lincoln, Mike and Lisowska, Agnes and McCowan, Iain and Post, Wilfried and Reidsma, Dennis and Wellner, Pierre},
30
- title = {The AMI Meeting Corpus: A Pre-Announcement},
31
- year = {2005},
32
- isbn = {3540325492},
33
- publisher = {Springer-Verlag},
34
- address = {Berlin, Heidelberg},
35
- url = {https://doi.org/10.1007/11677482_3},
36
- doi = {10.1007/11677482_3},
37
- abstract = {The AMI Meeting Corpus is a multi-modal data set consisting of 100 hours of meeting
38
- recordings. It is being created in the context of a project that is developing meeting
39
- browsing technology and will eventually be released publicly. Some of the meetings
40
- it contains are naturally occurring, and some are elicited, particularly using a scenario
41
- in which the participants play different roles in a design team, taking a design project
42
- from kick-off to completion over the course of a day. The corpus is being recorded
43
- using a wide range of devices including close-talking and far-field microphones, individual
44
- and room-view video cameras, projection, a whiteboard, and individual pens, all of
45
- which produce output signals that are synchronized with each other. It is also being
46
- hand-annotated for many different phenomena, including orthographic transcription,
47
- discourse properties such as named entities and dialogue acts, summaries, emotions,
48
- and some head and hand gestures. We describe the data set, including the rationale
49
- behind using elicited material, and explain how the material is being recorded, transcribed
50
- and annotated.},
51
- booktitle = {Proceedings of the Second International Conference on Machine Learning for Multimodal Interaction},
52
- pages = {28–39},
53
- numpages = {12},
54
- location = {Edinburgh, UK},
55
- series = {MLMI'05}
56
- }
57
- """
58
-
59
- _DESCRIPTION = """\
60
- The AMI Meeting Corpus consists of 100 hours of meeting recordings. The recordings use a range of signals
61
- synchronized to a common timeline. These include close-talking and far-field microphones, individual and
62
- room-view video cameras, and output from a slide projector and an electronic whiteboard. During the meetings,
63
- the participants also have unsynchronized pens available to them that record what is written. The meetings
64
- were recorded in English using three different rooms with different acoustic properties, and include mostly
65
- non-native speakers. \n
66
- """
67
-
68
- _HOMEPAGE = "https://groups.inf.ed.ac.uk/ami/corpus/"
69
-
70
- _LICENSE = "CC BY 4.0"
71
-
72
- _TRAIN_SAMPLE_IDS = [
73
- "EN2001a",
74
- "EN2001b",
75
- "EN2001d",
76
- "EN2001e",
77
- "EN2003a",
78
- "EN2004a",
79
- "EN2005a",
80
- "EN2006a",
81
- "EN2006b",
82
- "EN2009b",
83
- "EN2009c",
84
- "EN2009d",
85
- "ES2002a",
86
- "ES2002b",
87
- "ES2002c",
88
- "ES2002d",
89
- "ES2003a",
90
- "ES2003b",
91
- "ES2003c",
92
- "ES2003d",
93
- "ES2005a",
94
- "ES2005b",
95
- "ES2005c",
96
- "ES2005d",
97
- "ES2006a",
98
- "ES2006b",
99
- "ES2006c",
100
- "ES2006d",
101
- "ES2007a",
102
- "ES2007b",
103
- "ES2007c",
104
- "ES2007d",
105
- "ES2008a",
106
- "ES2008b",
107
- "ES2008c",
108
- "ES2008d",
109
- "ES2009a",
110
- "ES2009b",
111
- "ES2009c",
112
- "ES2009d",
113
- "ES2010a",
114
- "ES2010b",
115
- "ES2010c",
116
- "ES2010d",
117
- "ES2012a",
118
- "ES2012b",
119
- "ES2012c",
120
- "ES2012d",
121
- "ES2013a",
122
- "ES2013b",
123
- "ES2013c",
124
- "ES2013d",
125
- "ES2014a",
126
- "ES2014b",
127
- "ES2014c",
128
- "ES2014d",
129
- "ES2015a",
130
- "ES2015b",
131
- "ES2015c",
132
- "ES2015d",
133
- "ES2016a",
134
- "ES2016b",
135
- "ES2016c",
136
- "ES2016d",
137
- "IB4005",
138
- "IN1001",
139
- "IN1002",
140
- "IN1005",
141
- "IN1007",
142
- "IN1008",
143
- "IN1009",
144
- "IN1012",
145
- "IN1013",
146
- "IN1014",
147
- "IN1016",
148
- "IS1000a",
149
- "IS1000b",
150
- "IS1000c",
151
- "IS1000d",
152
- "IS1001a",
153
- "IS1001b",
154
- "IS1001c",
155
- "IS1001d",
156
- "IS1002b",
157
- "IS1002c",
158
- "IS1002d",
159
- "IS1003a",
160
- "IS1003b",
161
- "IS1003c",
162
- "IS1003d",
163
- "IS1004a",
164
- "IS1004b",
165
- "IS1004c",
166
- "IS1004d",
167
- "IS1005a",
168
- "IS1005b",
169
- "IS1005c",
170
- "IS1006a",
171
- "IS1006b",
172
- "IS1006c",
173
- "IS1006d",
174
- "IS1007a",
175
- "IS1007b",
176
- "IS1007c",
177
- "IS1007d",
178
- "TS3005a",
179
- "TS3005b",
180
- "TS3005c",
181
- "TS3005d",
182
- "TS3006a",
183
- "TS3006b",
184
- "TS3006c",
185
- "TS3006d",
186
- "TS3007a",
187
- "TS3007b",
188
- "TS3007c",
189
- "TS3007d",
190
- "TS3008a",
191
- "TS3008b",
192
- "TS3008c",
193
- "TS3008d",
194
- "TS3009a",
195
- "TS3009b",
196
- "TS3009c",
197
- "TS3009d",
198
- "TS3010a",
199
- "TS3010b",
200
- "TS3010c",
201
- "TS3010d",
202
- "TS3011a",
203
- "TS3011b",
204
- "TS3011c",
205
- "TS3011d",
206
- "TS3012a",
207
- "TS3012b",
208
- "TS3012c",
209
- "TS3012d",
210
- ]
211
-
212
- _TRAIN_SAMPLES_BROKEN_SDM = ["IS1003b", "IS1007d"]
213
-
214
- _VALIDATION_SAMPLE_IDS = [
215
- "ES2011a",
216
- "ES2011c",
217
- "IB4001",
218
- "IB4003",
219
- "IB4010",
220
- "IS1008a",
221
- "IS1008c",
222
- "TS3004a",
223
- "TS3004c",
224
- "ES2011b",
225
- "ES2011d",
226
- "IB4002",
227
- "IB4004",
228
- "IB4011",
229
- "IS1008b",
230
- "IS1008d",
231
- "TS3004b",
232
- "TS3004d",
233
- ]
234
-
235
- _EVAL_SAMPLE_IDS = [
236
- "EN2002a",
237
- "EN2002b",
238
- "EN2002c",
239
- "EN2002d",
240
- "ES2004a",
241
- "ES2004b",
242
- "ES2004c",
243
- "ES2004d",
244
- "IS1009a",
245
- "IS1009b",
246
- "IS1009c",
247
- "IS1009d",
248
- "TS3003a",
249
- "TS3003b",
250
- "TS3003c",
251
- "TS3003d",
252
- ]
253
-
254
- _SAMPLE_IDS = {
255
- "train": _TRAIN_SAMPLE_IDS,
256
- "dev": _VALIDATION_SAMPLE_IDS,
257
- "eval": _EVAL_SAMPLE_IDS,
258
- }
259
-
260
- _SUBSETS = ("ihm", "sdm")
261
-
262
- _BASE_DATA_URL = "https://huggingface.co/datasets/edinburghcstr/ami/resolve/main/"
263
-
264
- _AUDIO_ARCHIVE_URL = _BASE_DATA_URL + "audio/{subset}/{split}/{_id}.tar.gz"
265
-
266
- _ANNOTATIONS_ARCHIVE_URL = _BASE_DATA_URL + "annotations/{split}/text"
267
-
268
- logger = datasets.utils.logging.get_logger(__name__)
269
-
270
-
271
- class AMIConfig(datasets.BuilderConfig):
272
- """BuilderConfig for AMI."""
273
-
274
- def __init__(self, name, *args, **kwargs):
275
- """BuilderConfig for AMI"""
276
- super().__init__(name=name, *args, **kwargs)
277
-
278
-
279
- class AMI(datasets.GeneratorBasedBuilder):
280
-
281
- VERSION = datasets.Version("1.0.0")
282
-
283
- BUILDER_CONFIGS = [
284
- AMIConfig(name=subset) for subset in _SUBSETS
285
- ]
286
-
287
- DEFAULT_WRITER_BATCH_SIZE = 128
288
-
289
- def _info(self):
290
- features = datasets.Features(
291
- {
292
- "meeting_id": datasets.Value("string"),
293
- "audio_id": datasets.Value("string"),
294
- "text": datasets.Value("string"),
295
- "audio": datasets.Audio(sampling_rate=16_000),
296
- "begin_time": datasets.Value("float32"),
297
- "end_time": datasets.Value("float32"),
298
- "microphone_id": datasets.Value("string"),
299
- "speaker_id": datasets.Value("string"),
300
- }
301
- )
302
- return datasets.DatasetInfo(
303
- description=_DESCRIPTION,
304
- features=features,
305
- homepage=_HOMEPAGE,
306
- license=_LICENSE,
307
- citation=_CITATION,
308
- )
309
-
310
- def _split_generators(self, dl_manager):
311
- splits = ["train", "dev", "eval"]
312
-
313
- audio_archives_urls = {}
314
- for split in splits:
315
- split_ids = _SAMPLE_IDS[split]
316
-
317
- if self.config.name == "sdm" and split == "train":
318
- split_ids = [s for s in split_ids if s not in _TRAIN_SAMPLES_BROKEN_SDM]
319
-
320
- audio_archives_urls[split] = [
321
- _AUDIO_ARCHIVE_URL.format(subset=self.config.name, split=split, _id=m) for m in split_ids
322
- ]
323
-
324
- audio_archives = dl_manager.download(audio_archives_urls)
325
- local_extracted_archives_paths = dl_manager.extract(audio_archives) if not dl_manager.is_streaming else {
326
- split: [None] * len(audio_archives[split]) for split in splits
327
- }
328
-
329
- annotations_urls = {split: _ANNOTATIONS_ARCHIVE_URL.format(split=split) for split in splits}
330
- annotations = dl_manager.download(annotations_urls)
331
-
332
- return [
333
- datasets.SplitGenerator(
334
- name=datasets.Split.TRAIN,
335
- gen_kwargs={
336
- "audio_archives": [dl_manager.iter_archive(archive) for archive in audio_archives["train"]],
337
- "local_extracted_archives_paths": local_extracted_archives_paths["train"],
338
- "annotation": annotations["train"],
339
- "split": "train"
340
- },
341
- ),
342
- datasets.SplitGenerator(
343
- name=datasets.Split.VALIDATION,
344
- gen_kwargs={
345
- "audio_archives": [dl_manager.iter_archive(archive) for archive in audio_archives["dev"]],
346
- "local_extracted_archives_paths": local_extracted_archives_paths["dev"],
347
- "annotation": annotations["dev"],
348
- "split": "dev"
349
- },
350
- ),
351
- datasets.SplitGenerator(
352
- name=datasets.Split.TEST,
353
- gen_kwargs={
354
- "audio_archives": [dl_manager.iter_archive(archive) for archive in audio_archives["eval"]],
355
- "local_extracted_archives_paths": local_extracted_archives_paths["eval"],
356
- "annotation": annotations["eval"],
357
- "split": "eval"
358
- },
359
- ),
360
- ]
361
-
362
- def _generate_examples(self, audio_archives, local_extracted_archives_paths, annotation, split):
363
- # open annotation file
364
- assert len(audio_archives) == len(local_extracted_archives_paths)
365
-
366
- with open(annotation, "r", encoding="utf-8") as f:
367
- transcriptions = {}
368
- for line in f.readlines():
369
- line_items = line.strip().split()
370
- _id = line_items[0]
371
- text = " ".join(line_items[1:])
372
- _, meeting_id, microphone_id, speaker_id, begin_time, end_time = _id.split("_")
373
-
374
- # sdm specific
375
- if self.config.name == "sdm" and meeting_id in _TRAIN_SAMPLES_BROKEN_SDM:
376
- continue
377
- elif self.config.name == "sdm":
378
- microphone_id = "SDM1"
379
- _id_items = _id.split("_")
380
- _id = "_".join(_id_items[:2] + ["sdm"] + _id_items[3:])
381
-
382
- audio_filename = "_".join([split, _id.lower()]) + ".wav"
383
-
384
- transcriptions[audio_filename] = {
385
- "audio_id": _id,
386
- "meeting_id": meeting_id,
387
- "text": text,
388
- "begin_time": int(begin_time) / 100,
389
- "end_time": int(end_time) / 100,
390
- "microphone_id": microphone_id,
391
- "speaker_id": speaker_id,
392
- }
393
-
394
- features = ["meeting_id", "audio_id", "text", "begin_time", "end_time", "microphone_id", "speaker_id"]
395
- for archive, local_archive_path in zip(audio_archives, local_extracted_archives_paths):
396
- for audio_path, audio_file in archive:
397
- # adapt for sdm
398
- if self.config.name == "sdm":
399
- _audio_path_items = audio_path.split("_")
400
- audio_path = "_".join(_audio_path_items[:3] + ["sdm"] + _audio_path_items[4:])
401
-
402
- # audio_path is like 'EN2001a/train_ami_en2001a_h00_mee068_0414915_0415078.wav'
403
- audio_meta = transcriptions[audio_path.split("/")[-1]]
404
-
405
- yield audio_path, {
406
- "audio": {
407
- "path": os.path.join(local_archive_path, audio_path) if local_archive_path else audio_path,
408
- "bytes": audio_file.read(),
409
- },
410
- **{feature: audio_meta[feature] for feature in features}
411
- }