system HF staff commited on
Commit
833e3d4
1 Parent(s): 7052381

Update files from the datasets library (from 1.13.3)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.13.3

Files changed (2) hide show
  1. README.md +4 -2
  2. common_voice.py +10 -1
README.md CHANGED
@@ -254,7 +254,7 @@ English
254
  A typical data point comprises the path to the audio file, called path and its sentence. Additional fields include accent, age, client_id, up_votes down_votes, gender, locale and segment.
255
 
256
  `
257
- {'accent': 'netherlands', 'age': 'fourties', 'client_id': 'bbbcb732e0f422150c30ff3654bbab572e2a617da107bca22ff8b89ab2e4f124d03b6a92c48322862f60bd0179ae07baf0f9b4f9c4e11d581e0cec70f703ba54', 'down_votes': 0, 'gender': 'male', 'locale': 'nl', 'path': 'nl/clips/common_voice_nl_23522441.mp3', 'segment': "''", 'sentence': 'Ik vind dat een dubieuze procedure.', 'up_votes': 2}
258
  `
259
 
260
  ### Data Fields
@@ -263,6 +263,8 @@ client_id: An id for which client (voice) made the recording
263
 
264
  path: The path to the audio file
265
 
 
 
266
  sentence: The sentence the user was prompted to speak
267
 
268
  up_votes: How many upvotes the audio file has received from reviewers
@@ -362,4 +364,4 @@ The dataset consists of people who have donated their voice online. You agree t
362
 
363
  ### Contributions
364
 
365
- Thanks to [@BirgerMoell](https://github.com/BirgerMoell) for adding this dataset.
 
254
  A typical data point comprises the path to the audio file, called path and its sentence. Additional fields include accent, age, client_id, up_votes down_votes, gender, locale and segment.
255
 
256
  `
257
+ {'accent': 'netherlands', 'age': 'fourties', 'client_id': 'bbbcb732e0f422150c30ff3654bbab572e2a617da107bca22ff8b89ab2e4f124d03b6a92c48322862f60bd0179ae07baf0f9b4f9c4e11d581e0cec70f703ba54', 'down_votes': 0, 'gender': 'male', 'locale': 'nl', 'path': 'nl/clips/common_voice_nl_23522441.mp3', 'segment': "''", 'sentence': 'Ik vind dat een dubieuze procedure.', 'up_votes': 2, 'audio': {'path': `nl/clips/common_voice_nl_23522441.mp3', 'array': array([-0.00048828, -0.00018311, -0.00137329, ..., 0.00079346, 0.00091553, 0.00085449], dtype=float32), 'sampling_rate': 48000}
258
  `
259
 
260
  ### Data Fields
 
263
 
264
  path: The path to the audio file
265
 
266
+ audio: A dictionary containing the path to the downloaded audio file, the decoded audio array, and the sampling rate. Note that when accessing the audio column: `dataset[0]["audio"]` the audio file is automatically decoded and resampled to `dataset.features["audio"].sampling_rate`. Decoding and resampling of a large number of audio files might take a significant amount of time. Thus it is important to first query the sample index before the `"audio"` column, *i.e.* `dataset[0]["audio"]` should **always** be preferred over `dataset["audio"][0]`.
267
+
268
  sentence: The sentence the user was prompted to speak
269
 
270
  up_votes: How many upvotes the audio file has received from reviewers
 
364
 
365
  ### Contributions
366
 
367
+ Thanks to [@BirgerMoell](https://github.com/BirgerMoell) for adding this dataset.
common_voice.py CHANGED
@@ -632,6 +632,7 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
632
  {
633
  "client_id": datasets.Value("string"),
634
  "path": datasets.Value("string"),
 
635
  "sentence": datasets.Value("string"),
636
  "up_votes": datasets.Value("int64"),
637
  "down_votes": datasets.Value("int64"),
@@ -702,6 +703,9 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
702
  def _generate_examples(self, filepath, path_to_clips):
703
  """Yields examples."""
704
  data_fields = list(self._info().features.keys())
 
 
 
705
  path_idx = data_fields.index("path")
706
 
707
  with open(filepath, encoding="utf-8") as f:
@@ -723,4 +727,9 @@ class CommonVoice(datasets.GeneratorBasedBuilder):
723
  if len(field_values) < len(data_fields):
724
  field_values += (len(data_fields) - len(field_values)) * ["''"]
725
 
726
- yield id_, {key: value for key, value in zip(data_fields, field_values)}
 
 
 
 
 
 
632
  {
633
  "client_id": datasets.Value("string"),
634
  "path": datasets.Value("string"),
635
+ "audio": datasets.features.Audio(sampling_rate=48_000),
636
  "sentence": datasets.Value("string"),
637
  "up_votes": datasets.Value("int64"),
638
  "down_votes": datasets.Value("int64"),
 
703
  def _generate_examples(self, filepath, path_to_clips):
704
  """Yields examples."""
705
  data_fields = list(self._info().features.keys())
706
+
707
+ # audio is not a header of the csv files
708
+ data_fields.remove("audio")
709
  path_idx = data_fields.index("path")
710
 
711
  with open(filepath, encoding="utf-8") as f:
 
727
  if len(field_values) < len(data_fields):
728
  field_values += (len(data_fields) - len(field_values)) * ["''"]
729
 
730
+ result = {key: value for key, value in zip(data_fields, field_values)}
731
+
732
+ # set audio feature
733
+ result["audio"] = field_values[path_idx]
734
+
735
+ yield id_, result