Seosnaps commited on
Commit
63f1b63
1 Parent(s): aa4acb4

Update hausa_2_eng_2.py

Browse files
Files changed (1) hide show
  1. hausa_2_eng_2.py +10 -51
hausa_2_eng_2.py CHANGED
@@ -13,59 +13,21 @@ from .languages import LANGUAGES
13
  from .release_stats import STATS
14
 
15
 
16
- _CITATION = """\
17
- @inproceedings{commonvoice:2020,
18
- author = {Ardila, R. and Branson, M. and Davis, K. and Henretty, M. and Kohler, M. and Meyer, J. and Morais, R. and Saunders, L. and Tyers, F. M. and Weber, G.},
19
- title = {Common Voice: A Massively-Multilingual Speech Corpus},
20
- booktitle = {Proceedings of the 12th Conference on Language Resources and Evaluation (LREC 2020)},
21
- pages = {4211--4215},
22
- year = 2020
23
- }
24
- """
25
 
26
 
27
 
28
 
29
- _HOMEPAGE = "https://commonvoice.mozilla.org/en/datasets"
30
 
31
  _BASE_URL = "https://huggingface.co/datasets/Seon25/hausa_2_eng_2/resolve/main"
32
 
33
- _AUDIO_URL = _BASE_URL + "audio/{lang}/{split}/{lang}_{split}_{shard_idx}.tar"
34
 
35
- _TRANSCRIPT_URL = _BASE_URL + "transcript/{lang}/{split}.tsv"
36
-
37
- _N_SHARDS_URL = _BASE_URL + "n_shards.json"
38
-
39
-
40
- class Hausa2EngConfig(datasets.BuilderConfig):
41
- """BuilderConfig for CommonVoice."""
42
-
43
- def __init__(self, name, version, **kwargs):
44
- self.language = kwargs.pop("language", None)
45
- self.release_date = kwargs.pop("release_date", None)
46
- self.num_clips = kwargs.pop("num_clips", None)
47
- self.num_speakers = kwargs.pop("num_speakers", None)
48
- self.validated_hr = kwargs.pop("validated_hr", None)
49
- self.total_hr = kwargs.pop("total_hr", None)
50
- self.size_bytes = kwargs.pop("size_bytes", None)
51
- self.size_human = size_str(self.size_bytes)
52
- description = (
53
- f"Common Voice speech to text dataset in {self.language} released on {self.release_date}. "
54
- f"The dataset comprises {self.validated_hr} hours of validated transcribed speech data "
55
- f"out of {self.total_hr} hours in total from {self.num_speakers} speakers. "
56
- f"The dataset contains {self.num_clips} audio clips and has a size of {self.size_human}."
57
- )
58
- super(Hausa2EngConfig, self).__init__(
59
- name=name,
60
- version=datasets.Version(version),
61
- description=description,
62
- **kwargs,
63
- )
64
 
65
 
66
 
67
  class Hausa2Eng(datasets.GeneratorBasedBuilder):
68
- DEFAULT_WRITER_BATCH_SIZE = 1000
69
 
70
  BUILDER_CONFIGS = [
71
  Hausa2EngConfig(
@@ -83,12 +45,12 @@ class Hausa2Eng(datasets.GeneratorBasedBuilder):
83
  ]
84
 
85
  def _info(self):
86
- total_languages = len(STATS["locales"])
87
  total_valid_hours = STATS["totalValidHrs"]
88
  description = (
89
  "Common Voice is Mozilla's initiative to help teach machines how real people speak. "
90
- f"The dataset currently consists of {total_valid_hours} validated hours of speech "
91
- f" in {total_languages} languages, but more voices and languages are always added."
92
  )
93
  features = datasets.Features(
94
  {
@@ -111,14 +73,11 @@ class Hausa2Eng(datasets.GeneratorBasedBuilder):
111
  description=description,
112
  features=features,
113
  supervised_keys=None,
114
- homepage=_HOMEPAGE,
115
- license=_LICENSE,
116
- citation=_CITATION,
117
- version=self.config.version,
118
  )
119
 
120
  def _split_generators(self, dl_manager):
121
- lang = self.config.name
122
  n_shards_path = dl_manager.download_and_extract(_N_SHARDS_URL)
123
  with open(n_shards_path, encoding="utf-8") as f:
124
  n_shards = json.load(f)
@@ -127,12 +86,12 @@ class Hausa2Eng(datasets.GeneratorBasedBuilder):
127
  splits = ("train", "dev", "test", "other", "invalidated")
128
  for split in splits:
129
  audio_urls[split] = [
130
- _AUDIO_URL.format(lang=lang, split=split, shard_idx=i) for i in range(n_shards[lang][split])
131
  ]
132
  archive_paths = dl_manager.download(audio_urls)
133
  local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
134
 
135
- meta_urls = {split: _TRANSCRIPT_URL.format(lang=lang, split=split) for split in splits}
136
  meta_paths = dl_manager.download_and_extract(meta_urls)
137
 
138
  split_generators = []
 
13
  from .release_stats import STATS
14
 
15
 
 
 
 
 
 
 
 
 
 
16
 
17
 
18
 
19
 
 
20
 
21
  _BASE_URL = "https://huggingface.co/datasets/Seon25/hausa_2_eng_2/resolve/main"
22
 
23
+ _AUDIO_URL = _BASE_URL + "audio/ha/{split}/ha_{split}_0.tar"
24
 
25
+ _TRANSCRIPT_URL = _BASE_URL + "transcript/ha/{split}.tsv"
26
+ _N_SHARDS_URL ="n_shards.json"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
 
29
 
30
  class Hausa2Eng(datasets.GeneratorBasedBuilder):
 
31
 
32
  BUILDER_CONFIGS = [
33
  Hausa2EngConfig(
 
45
  ]
46
 
47
  def _info(self):
48
+
49
  total_valid_hours = STATS["totalValidHrs"]
50
  description = (
51
  "Common Voice is Mozilla's initiative to help teach machines how real people speak. "
52
+ f"The dataset currently consists of validated hours of speech "
53
+ f" in languages, but more voices and languages are always added."
54
  )
55
  features = datasets.Features(
56
  {
 
73
  description=description,
74
  features=features,
75
  supervised_keys=None,
76
+
 
 
 
77
  )
78
 
79
  def _split_generators(self, dl_manager):
80
+ lang = "ha"
81
  n_shards_path = dl_manager.download_and_extract(_N_SHARDS_URL)
82
  with open(n_shards_path, encoding="utf-8") as f:
83
  n_shards = json.load(f)
 
86
  splits = ("train", "dev", "test", "other", "invalidated")
87
  for split in splits:
88
  audio_urls[split] = [
89
+ _AUDIO_URL.format(lang="ha", split=split, 0)
90
  ]
91
  archive_paths = dl_manager.download(audio_urls)
92
  local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
93
 
94
+ meta_urls = {split: _TRANSCRIPT_URL.format(lang="ha", split=split) for split in splits}
95
  meta_paths = dl_manager.download_and_extract(meta_urls)
96
 
97
  split_generators = []