Nikita Pavlichenko commited on
Commit
907dd52
1 Parent(s): c2c3579

First version of VoxDIY

Browse files
Files changed (1) hide show
  1. VoxDIY-RusNews.py +105 -0
VoxDIY-RusNews.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2021 YANDEX LLC.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """VoxDIY: Benchmark Dataset for Russian Crowdsourced Audio Transcription."""
18
+
19
+
20
+ import json
21
+
22
+ import datasets
23
+ from datasets.tasks import Summarization
24
+
25
+
26
+ logger = datasets.logging.get_logger(__name__)
27
+
28
+ _DESCRIPTION = """\
29
+ VoxDIY: Benchmark Dataset for Russian Crowdsourced Audio Transcription.
30
+ """
31
+
32
+ _URL = "https://raw.githubusercontent.com/pilot7747/VoxDIY/main/data/huggingface/"
33
+ _URLS = {
34
+ "train": "vox-diy-rusnews.json"
35
+ }
36
+
37
+
38
+ class VoxDIYRusNewsConfig(datasets.BuilderConfig):
39
+ """BuilderConfig for VoxDIY-RusNews."""
40
+
41
+ def __init__(self, **kwargs):
42
+ """BuilderConfig for VoxDIY-RusNews.
43
+
44
+ Args:
45
+ **kwargs: keyword arguments forwarded to super.
46
+ """
47
+ super(CrowdSpeechConfig, self).__init__(**kwargs)
48
+
49
+
50
+ class VoxDIYRusNews(datasets.GeneratorBasedBuilder):
51
+ """VoxDIY: Benchmark Dataset for Russian Crowdsourced Audio Transcription."""
52
+
53
+ BUILDER_CONFIGS = [
54
+ VoxDIYRusNewsConfig(
55
+ name="plain_text",
56
+ version=datasets.Version("1.0.0", ""),
57
+ description="Plain text",
58
+ ),
59
+ ]
60
+
61
+ def _info(self):
62
+ return datasets.DatasetInfo(
63
+ description=_DESCRIPTION,
64
+ features=datasets.Features(
65
+ {
66
+ "task": datasets.Value("string"),
67
+ "transcriptions": datasets.Value("string"),
68
+ "performers": datasets.Value("string"),
69
+ "gt": datasets.Value("string"),
70
+ }
71
+ ),
72
+ supervised_keys=None,
73
+ homepage="https://github.com/pilot7747/VoxDIY/",
74
+ # citation=_CITATION,
75
+ task_templates=[
76
+ Summarization(
77
+ text_column="transcriptions", summary_column="gt"
78
+ )
79
+ ],
80
+ )
81
+
82
+ def _split_generators(self, dl_manager):
83
+ downloaded_files = dl_manager.download_and_extract(_URLS)
84
+
85
+ return [
86
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
87
+ ]
88
+
89
+ def _generate_examples(self, filepath):
90
+ """This function returns the examples in the raw (text) form."""
91
+ logger.info("generating examples from = %s", filepath)
92
+ with open(filepath, encoding="utf-8") as f:
93
+ crowdspeech = json.load(f)
94
+ for audio in crowdspeech["data"]:
95
+ task = audio.get("task", "")
96
+ transcriptions = audio.get("transcriptions", "")
97
+ performers = audio.get("performers", "")
98
+ gt = audio.get("gt", "")
99
+
100
+ yield task, {
101
+ "task": task,
102
+ "transcriptions": transcriptions,
103
+ "performers": performers,
104
+ "gt": gt,
105
+ }