keshan commited on
Commit
c8b97e5
1 Parent(s): 76c7ab9

updatinf data files

Browse files
.ipynb_checkpoints/large-sinhala-asr-dataset-checkpoint.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import string
3
+
4
+ import datasets
5
+ from datasets.tasks import AutomaticSpeechRecognition
6
+
7
+
8
+ _DATA_URL = "https://www.openslr.org/resources/52/asr_sinhala_{}.zip"
9
+
10
+ _CITATION = """\
11
+ @inproceedings{kjartansson-etal-sltu2018,
12
+ title = {{Crowd-Sourced Speech Corpora for Javanese, Sundanese, Sinhala, Nepali, and Bangladeshi Bengali}},
13
+ author = {Oddur Kjartansson and Supheakmungkol Sarin and Knot Pipatsrisawat and Martin Jansche and Linne Ha},
14
+ booktitle = {Proc. The 6th Intl. Workshop on Spoken Language Technologies for Under-Resourced Languages (SLTU)},
15
+ year = {2018},
16
+ address = {Gurugram, India},
17
+ month = aug,
18
+ pages = {52--55},
19
+ URL = {http://dx.doi.org/10.21437/SLTU.2018-11}
20
+ }
21
+ """
22
+
23
+ _DESCRIPTION = """\
24
+ This data set contains ~185K transcribed audio data for Sinhala. The data set consists of wave files, and a TSV file. The file utt_spk_text.tsv contains a FileID, anonymized UserID and the transcription of audio in the file.
25
+ The data set has been manually quality checked, but there might still be errors.
26
+
27
+ See LICENSE.txt file for license information.
28
+
29
+ Copyright 2016, 2017, 2018 Google, Inc.
30
+ """
31
+
32
+ _HOMEPAGE = "https://www.openslr.org/52/"
33
+
34
+ _LICENSE = "https://www.openslr.org/resources/52/LICENSE"
35
+
36
+ _LANGUAGES = {
37
+ "si": {
38
+ "Language": "Sinhala",
39
+ "Date": "2018",
40
+ },
41
+ }
42
+
43
+
44
+ class LargeASRConfig(datasets.BuilderConfig):
45
+ """BuilderConfig for LargeASR."""
46
+
47
+ def __init__(self, name, **kwargs):
48
+ """
49
+ Args:
50
+ data_dir: `string`, the path to the folder containing the files in the
51
+ downloaded .tar
52
+ citation: `string`, citation for the data set
53
+ url: `string`, url for information about the data set
54
+ **kwargs: keyword arguments forwarded to super.
55
+ """
56
+ self.language = kwargs.pop("language", None)
57
+ self.date_of_snapshot = kwargs.pop("date", None)
58
+ description = f"Large Sinhala dataset in {self.language} of {self.date_of_snapshot}."
59
+ super(LargeASRConfig, self).__init__(
60
+ name=name, version=datasets.Version("1.0.0", ""), description=description, **kwargs
61
+ )
62
+
63
+
64
+ class LargeASR(datasets.GeneratorBasedBuilder):
65
+
66
+ BUILDER_CONFIGS = [
67
+ LargeASRConfig(
68
+ name=lang_id,
69
+ language=_LANGUAGES[lang_id]["Language"],
70
+ date=_LANGUAGES[lang_id]["Date"],
71
+ )
72
+ for lang_id in _LANGUAGES.keys()
73
+ ]
74
+
75
+ def _info(self):
76
+ features = datasets.Features(
77
+ {
78
+ "filename": datasets.Value("string"),
79
+ "x": datasets.Value("string"),
80
+ "sentence": datasets.Value("string"),
81
+ "file": datasets.Value("string"),
82
+ }
83
+ )
84
+
85
+ return datasets.DatasetInfo(
86
+ description=_DESCRIPTION,
87
+ features=features,
88
+ supervised_keys=None,
89
+ homepage=_HOMEPAGE,
90
+ license=_LICENSE,
91
+ citation=_CITATION,
92
+ task_templates=[
93
+ AutomaticSpeechRecognition(audio_file_path_column="file", transcription_column="sentence")
94
+ ],
95
+ )
96
+
97
+ def _split_generators(self, dl_manager):
98
+ """Returns SplitGenerators."""
99
+ data_urls = [_DATA_URL.format(i) for i in (string.digits + string.ascii_lowercase[:6])]
100
+ dl_path = dl_manager.download_and_extract(data_urls)
101
+ print(dl_path)
102
+ abs_path_to_data = os.path.join('./')
103
+ abs_path_to_clips = os.path.join(dl_path)
104
+
105
+ return [
106
+ datasets.SplitGenerator(
107
+ name=datasets.Split.TRAIN,
108
+ gen_kwargs={
109
+ "filepath": os.path.join(abs_path_to_data, "train.tsv"),
110
+ "path_to_clips": abs_path_to_clips,
111
+ },
112
+ ),
113
+ datasets.SplitGenerator(
114
+ name=datasets.Split.TEST,
115
+ gen_kwargs={
116
+ "filepath": os.path.join(abs_path_to_data, "test.tsv"),
117
+ "path_to_clips": abs_path_to_clips,
118
+ },
119
+ ),
120
+ ]
121
+
122
+ def _generate_examples(self, filepath, path_to_clips):
123
+ """Yields examples."""
124
+ data_fields = list(self._info().features.keys())
125
+ path_idx = data_fields.index("file")
126
+
127
+ with open(filepath, encoding="utf-8") as f:
128
+ lines = f.readlines()
129
+ headline = lines[0]
130
+
131
+ column_names = headline.strip().split("\t")
132
+ assert (
133
+ column_names == data_fields
134
+ ), f"The file should have {data_fields} as column names, but has {column_names}"
135
+
136
+ for id_, line in enumerate(lines[1:]):
137
+ field_values = line.strip().split("\t")
138
+
139
+ # set absolute path for wav audio file
140
+ field_values[path_idx] = os.path.join(path_to_clips, field_values[path_idx])
141
+
142
+ # if data is incomplete, fill with empty values
143
+ if len(field_values) < len(data_fields):
144
+ field_values += (len(data_fields) - len(field_values)) * ["''"]
145
+
146
+ yield id_, {key: value for key, value in zip(data_fields, field_values)}
large-sinhala-asr-dataset.py CHANGED
@@ -1,10 +1,11 @@
1
  import os
 
2
 
3
  import datasets
4
  from datasets.tasks import AutomaticSpeechRecognition
5
 
6
 
7
- _DATA_URL = ".tar.gz"
8
 
9
  _CITATION = """\
10
  @inproceedings{kjartansson-etal-sltu2018,
@@ -20,7 +21,7 @@ _CITATION = """\
20
  """
21
 
22
  _DESCRIPTION = """\
23
- This data set contains transcribed audio data for Sinhala. The data set consists of wave files, and a TSV file. The file utt_spk_text.tsv contains a FileID, anonymized UserID and the transcription of audio in the file.
24
  The data set has been manually quality checked, but there might still be errors.
25
 
26
  See LICENSE.txt file for license information.
@@ -35,12 +36,7 @@ _LICENSE = "https://www.openslr.org/resources/52/LICENSE"
35
  _LANGUAGES = {
36
  "si": {
37
  "Language": "Sinhala",
38
- "Date": "2020-12-11",
39
- "Size": "39 MB",
40
- "Version": "si_1h_2020-12-11",
41
- "Validated_Hr_Total": 0.05,
42
- "Overall_Hr_Total": 1,
43
- "Number_Of_Voice": 14,
44
  },
45
  }
46
 
@@ -48,7 +44,7 @@ _LANGUAGES = {
48
  class LargeASRConfig(datasets.BuilderConfig):
49
  """BuilderConfig for LargeASR."""
50
 
51
- def __init__(self, name, sub_version, **kwargs):
52
  """
53
  Args:
54
  data_dir: `string`, the path to the folder containing the files in the
@@ -57,14 +53,9 @@ class LargeASRConfig(datasets.BuilderConfig):
57
  url: `string`, url for information about the data set
58
  **kwargs: keyword arguments forwarded to super.
59
  """
60
- self.sub_version = sub_version
61
  self.language = kwargs.pop("language", None)
62
  self.date_of_snapshot = kwargs.pop("date", None)
63
- self.size = kwargs.pop("size", None)
64
- self.validated_hr_total = kwargs.pop("val_hrs", None)
65
- self.total_hr_total = kwargs.pop("total_hrs", None)
66
- self.num_of_voice = kwargs.pop("num_of_voice", None)
67
- description = f"Large Sinhala dataset in {self.language} version {self.sub_version} of {self.date_of_snapshot}. The dataset comprises {self.validated_hr_total} of validated transcribed speech data from {self.num_of_voice} speakers. The dataset has a size of {self.size}"
68
  super(LargeASRConfig, self).__init__(
69
  name=name, version=datasets.Version("1.0.0", ""), description=description, **kwargs
70
  )
@@ -76,12 +67,7 @@ class LargeASR(datasets.GeneratorBasedBuilder):
76
  LargeASRConfig(
77
  name=lang_id,
78
  language=_LANGUAGES[lang_id]["Language"],
79
- sub_version=_LANGUAGES[lang_id]["Version"],
80
  date=_LANGUAGES[lang_id]["Date"],
81
- size=_LANGUAGES[lang_id]["Size"],
82
- val_hrs=_LANGUAGES[lang_id]["Validated_Hr_Total"],
83
- total_hrs=_LANGUAGES[lang_id]["Overall_Hr_Total"],
84
- num_of_voice=_LANGUAGES[lang_id]["Number_Of_Voice"],
85
  )
86
  for lang_id in _LANGUAGES.keys()
87
  ]
@@ -92,7 +78,6 @@ class LargeASR(datasets.GeneratorBasedBuilder):
92
  "filename": datasets.Value("string"),
93
  "x": datasets.Value("string"),
94
  "sentence": datasets.Value("string"),
95
- "full": datasets.Value("string"),
96
  "file": datasets.Value("string"),
97
  }
98
  )
@@ -111,9 +96,11 @@ class LargeASR(datasets.GeneratorBasedBuilder):
111
 
112
  def _split_generators(self, dl_manager):
113
  """Returns SplitGenerators."""
114
- # dl_path = dl_manager.download_and_extract(_DATA_URL)
115
- # abs_path_to_data = os.path.join(dl_path, "cv-corpus-6.1-2020-12-11", self.config.name)
116
- # abs_path_to_clips = os.path.join(abs_path_to_data, "clips")
 
 
117
 
118
  return [
119
  datasets.SplitGenerator(
1
  import os
2
+ import string
3
 
4
  import datasets
5
  from datasets.tasks import AutomaticSpeechRecognition
6
 
7
 
8
+ _DATA_URL = "https://www.openslr.org/resources/52/asr_sinhala_{}.zip"
9
 
10
  _CITATION = """\
11
  @inproceedings{kjartansson-etal-sltu2018,
21
  """
22
 
23
  _DESCRIPTION = """\
24
+ This data set contains ~185K transcribed audio data for Sinhala. The data set consists of wave files, and a TSV file. The file utt_spk_text.tsv contains a FileID, anonymized UserID and the transcription of audio in the file.
25
  The data set has been manually quality checked, but there might still be errors.
26
 
27
  See LICENSE.txt file for license information.
36
  _LANGUAGES = {
37
  "si": {
38
  "Language": "Sinhala",
39
+ "Date": "2018",
 
 
 
 
 
40
  },
41
  }
42
 
44
  class LargeASRConfig(datasets.BuilderConfig):
45
  """BuilderConfig for LargeASR."""
46
 
47
+ def __init__(self, name, **kwargs):
48
  """
49
  Args:
50
  data_dir: `string`, the path to the folder containing the files in the
53
  url: `string`, url for information about the data set
54
  **kwargs: keyword arguments forwarded to super.
55
  """
 
56
  self.language = kwargs.pop("language", None)
57
  self.date_of_snapshot = kwargs.pop("date", None)
58
+ description = f"Large Sinhala dataset in {self.language} of {self.date_of_snapshot}."
 
 
 
 
59
  super(LargeASRConfig, self).__init__(
60
  name=name, version=datasets.Version("1.0.0", ""), description=description, **kwargs
61
  )
67
  LargeASRConfig(
68
  name=lang_id,
69
  language=_LANGUAGES[lang_id]["Language"],
 
70
  date=_LANGUAGES[lang_id]["Date"],
 
 
 
 
71
  )
72
  for lang_id in _LANGUAGES.keys()
73
  ]
78
  "filename": datasets.Value("string"),
79
  "x": datasets.Value("string"),
80
  "sentence": datasets.Value("string"),
 
81
  "file": datasets.Value("string"),
82
  }
83
  )
96
 
97
  def _split_generators(self, dl_manager):
98
  """Returns SplitGenerators."""
99
+ data_urls = [_DATA_URL.format(i) for i in (string.digits + string.ascii_lowercase[:6])]
100
+ dl_path = dl_manager.download_and_extract(data_urls)
101
+ print(dl_path)
102
+ abs_path_to_data = os.path.join('./')
103
+ abs_path_to_clips = os.path.join(dl_path)
104
 
105
  return [
106
  datasets.SplitGenerator(
test.tsv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3f128900942286c77805da55efd4c6bdda0948146ead46b0c40f506ea4ac8c89
3
- size 3256626
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9aff9fa04dbaa71e7605ca1cca8e7550e8d1aac450e4671f972bc6e9c656b3eb
3
+ size 2886835
train.tsv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3f128900942286c77805da55efd4c6bdda0948146ead46b0c40f506ea4ac8c89
3
- size 3256626
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d95b9cf6f910d988454486a7feac59f935ee85efb5849d1f442d5feb6ab429f
3
+ size 16324488