cahya commited on
Commit
5da672b
·
1 Parent(s): c45df4d

add usage.py

Browse files
Files changed (3) hide show
  1. release_stats.py +4 -3
  2. test01.py +4 -21
  3. usage.py +10 -0
release_stats.py CHANGED
@@ -1,6 +1,7 @@
1
  STATS = {
2
- "name": "",
3
- "downloadUrl": "",
4
  "version": "1.0",
5
- "date": ""
 
6
  }
 
1
  STATS = {
2
+ "name": "Librivox-Indonesia",
3
+ "bundleURLTemplate": "https://huggingface.co/datasets/cahya/test01/resolve/main/audio.tgz",
4
  "version": "1.0",
5
+ "date": "",
6
+ "locales": {'reportedSentences': 261, 'buckets': {'dev': 3218, 'invalidated': 2454, 'other': 22787, 'reported': 260, 'test': 3622, 'train': 5043, 'validated': 23132}, 'duration': 196639788, 'clips': 48373, 'splits': {'accent': {'': 1}, 'age': {'': 0.26, 'twenties': 0.39, 'thirties': 0.07, 'teens': 0.26, 'fifties': 0, 'fourties': 0.02}, 'gender': {'': 0.26, 'male': 0.41, 'female': 0.29, 'other': 0.04}}, 'users': 416, 'size': 1253048208, 'checksum': '874e959e2ca1aacc502ff969a3e54de792dd41e4f672ae1fd9d38213f4bf4139', 'avgDurationSecs': 4.065, 'validDurationSecs': 94033.274, 'totalHrs': 54.62, 'validHrs': 26.12}
7
  }
test01.py CHANGED
@@ -34,6 +34,7 @@ _HOMEPAGE = "https://commonvoice.mozilla.org/en/datasets"
34
 
35
  _LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
36
 
 
37
 
38
  class Test01Config(datasets.BuilderConfig):
39
  """BuilderConfig for Test01."""
@@ -117,23 +118,6 @@ class Test01(datasets.GeneratorBasedBuilder):
117
  # ],
118
  )
119
 
120
- def _get_bundle_url(self, locale, url_template):
121
- # path = encodeURIComponent(path)
122
- path = url_template.replace("{locale}", locale)
123
- path = urllib.parse.quote(path.encode("utf-8"), safe="~()*!.'")
124
- # use_cdn = self.config.size_bytes < 20 * 1024 * 1024 * 1024
125
- # response = requests.get(f"{_API_URL}/bucket/dataset/{path}/{use_cdn}", timeout=10.0).json()
126
- response = requests.get(f"{_API_URL}/bucket/dataset/{path}", timeout=10.0).json()
127
- return response["url"]
128
-
129
- def _log_download(self, locale, bundle_version, auth_token):
130
- if isinstance(auth_token, bool):
131
- auth_token = HfFolder().get_token()
132
- whoami = HfApi().whoami(auth_token)
133
- email = whoami["email"] if "email" in whoami else ""
134
- payload = {"email": email, "locale": locale, "dataset": bundle_version}
135
- requests.post(f"{_API_URL}/{locale}/downloaders", json=payload).json()
136
-
137
  def _split_generators(self, dl_manager):
138
  """Returns SplitGenerators."""
139
  hf_auth_token = dl_manager.download_config.use_auth_token
@@ -146,15 +130,14 @@ class Test01(datasets.GeneratorBasedBuilder):
146
  bundle_version = bundle_url_template.split("/")[0]
147
  dl_manager.download_config.ignore_url_params = True
148
 
149
- self._log_download(self.config.name, bundle_version, hf_auth_token)
150
- archive_path = dl_manager.download(self._get_bundle_url(self.config.name, bundle_url_template))
151
  local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
152
 
153
  if self.config.version < datasets.Version("5.0.0"):
154
  path_to_data = ""
155
  else:
156
- path_to_data = "/".join([bundle_version, self.config.name])
157
- path_to_clips = "/".join([path_to_data, "clips"]) if path_to_data else "clips"
158
 
159
  return [
160
  datasets.SplitGenerator(
 
34
 
35
  _LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/"
36
 
37
+ _AUDIO_URL = "https://huggingface.co/datasets/cahya/test01/resolve/main/audio.tgz"
38
 
39
  class Test01Config(datasets.BuilderConfig):
40
  """BuilderConfig for Test01."""
 
118
  # ],
119
  )
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  def _split_generators(self, dl_manager):
122
  """Returns SplitGenerators."""
123
  hf_auth_token = dl_manager.download_config.use_auth_token
 
130
  bundle_version = bundle_url_template.split("/")[0]
131
  dl_manager.download_config.ignore_url_params = True
132
 
133
+ archive_path = dl_manager.download(_AUDIO_URL)
 
134
  local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
135
 
136
  if self.config.version < datasets.Version("5.0.0"):
137
  path_to_data = ""
138
  else:
139
+ path_to_data = ""
140
+ path_to_clips = "/".join([path_to_data, "audio"]) if path_to_data else "audio"
141
 
142
  return [
143
  datasets.SplitGenerator(
usage.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+
3
+
4
+ def main():
5
+ ds = load_dataset("./test01.py", "sun")
6
+ print(ds)
7
+
8
+
9
+ if __name__ == "__main__":
10
+ main()