HugoLaurencon HF staff commited on
Commit
8f48036
1 Parent(s): 4485095

with metadata

Browse files
Files changed (1) hide show
  1. libri_light.py +37 -37
libri_light.py CHANGED
@@ -92,38 +92,38 @@ class LibriLight(datasets.GeneratorBasedBuilder):
92
  "file": datasets.Value("string"),
93
  "audio": datasets.Audio(sampling_rate=16_000),
94
  "speaker_id": datasets.Value("int64"),
95
- #"metadata": {
96
- # "speaker": datasets.Value("string"),
97
- # "book_meta": {
98
- # "id": datasets.Value("string"),
99
- # "title": datasets.Value("string"),
100
- # "description": datasets.Value("string"),
101
- # "url_text_source": datasets.Value("string"),
102
- # "language": datasets.Value("string"),
103
- # "copyright_year": datasets.Value("string"),
104
- # "num_sections": datasets.Value("string"),
105
- # "url_rss": datasets.Value("string"),
106
- # "url_zip_file": datasets.Value("string"),
107
- # "url_project": datasets.Value("string"),
108
- # "url_librivox": datasets.Value("string"),
109
- # "url_other": datasets.Value("string"),
110
- # "totaltimesecs": datasets.Value("int64"),
111
- # "authors": datasets.Sequence(
112
- # {
113
- # "id": datasets.Value("string"),
114
- # "first_name": datasets.Value("string"),
115
- # "last_name": datasets.Value("string"),
116
- # "dob": datasets.Value("string"),
117
- # "dod": datasets.Value("string")
118
- # }
119
- # ),
120
- # "genre": datasets.Sequence(datasets.Value("string")),
121
- # "Dramatic Readings": datasets.Value("bool"),
122
- # "meta_genre": datasets.Value("string"),
123
- # },
124
- # "snr": datasets.Value("float32"),
125
- # "voice_activity": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
126
- #}
127
  }
128
  )
129
 
@@ -145,18 +145,18 @@ class LibriLight(datasets.GeneratorBasedBuilder):
145
  ]
146
 
147
  def _generate_examples(self, archive_path):
148
- paths = glob.glob(os.path.join(archive_path, "**", "**", "**", "*.flac"))
149
  for key, path in enumerate(paths):
150
  path_split = path.split("/")
151
  id_ = path_split[-1].replace(".flac", "")
152
  speaker_id = int(path_split[-3])
153
- #path_json = path.replace(".flac", ".json")
154
- #with open(path_json) as json_file:
155
- # metadata = json.load(json_file)
156
  yield key, {
157
  "id": id_,
158
  "file": path,
159
  "audio": path,
160
  "speaker_id": speaker_id,
161
- # "metadata": metadata,
162
  }
 
92
  "file": datasets.Value("string"),
93
  "audio": datasets.Audio(sampling_rate=16_000),
94
  "speaker_id": datasets.Value("int64"),
95
+ "metadata": {
96
+ "speaker": datasets.Value("string"),
97
+ "book_meta": {
98
+ "id": datasets.Value("string"),
99
+ "title": datasets.Value("string"),
100
+ "description": datasets.Value("string"),
101
+ "url_text_source": datasets.Value("string"),
102
+ "language": datasets.Value("string"),
103
+ "copyright_year": datasets.Value("string"),
104
+ "num_sections": datasets.Value("string"),
105
+ "url_rss": datasets.Value("string"),
106
+ "url_zip_file": datasets.Value("string"),
107
+ "url_project": datasets.Value("string"),
108
+ "url_librivox": datasets.Value("string"),
109
+ "url_other": datasets.Value("string"),
110
+ "totaltimesecs": datasets.Value("int64"),
111
+ "authors": datasets.Sequence(
112
+ {
113
+ "id": datasets.Value("string"),
114
+ "first_name": datasets.Value("string"),
115
+ "last_name": datasets.Value("string"),
116
+ "dob": datasets.Value("string"),
117
+ "dod": datasets.Value("string")
118
+ }
119
+ ),
120
+ "genre": datasets.Sequence(datasets.Value("string")),
121
+ "Dramatic Readings": datasets.Value("bool"),
122
+ "meta_genre": datasets.Value("string"),
123
+ },
124
+ "snr": datasets.Value("float32"),
125
+ "voice_activity": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
126
+ }
127
  }
128
  )
129
 
 
145
  ]
146
 
147
  def _generate_examples(self, archive_path):
148
+ paths = glob.glob(os.path.join(archive_path, "small", "**", "**", "*.flac"))
149
  for key, path in enumerate(paths):
150
  path_split = path.split("/")
151
  id_ = path_split[-1].replace(".flac", "")
152
  speaker_id = int(path_split[-3])
153
+ path_json = path.replace(".flac", ".json")
154
+ with open(path_json) as json_file:
155
+ metadata = json.load(json_file)
156
  yield key, {
157
  "id": id_,
158
  "file": path,
159
  "audio": path,
160
  "speaker_id": speaker_id,
161
+ "metadata": metadata,
162
  }