soeren commited on
Commit
c624b60
1 Parent(s): 72d08a5

ensure correct alignment between metadata and raw data

Browse files
data/clip_metadata.py CHANGED
@@ -7,4 +7,5 @@ df = pd.read_parquet("data/dataset_audio_" + _SPLIT +".parquet.gzip")
7
  clipped_df = df.filter(["label_string", "probability", "probability_vector", "prediction",
8
  "prediction_string", "embedding_reduced"], axis=1)
9
 
 
10
  clipped_df.to_parquet("data/dataset_audio_" + _SPLIT +"_clipped.parquet.gzip")
 
7
  clipped_df = df.filter(["label_string", "probability", "probability_vector", "prediction",
8
  "prediction_string", "embedding_reduced"], axis=1)
9
 
10
+ clipped_df = clipped_df.sort_values(by=["label_string"])
11
  clipped_df.to_parquet("data/dataset_audio_" + _SPLIT +"_clipped.parquet.gzip")
data/dataset_audio_test_clipped.parquet.gzip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:334324791b5c45096971f7bbf6a05afa60160d9ff5a9fc966762b9c2923cff02
3
- size 642187
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f547f9d8c86950a42baf9ddf1a5a52cd04a8edc9200529ddf61cea4902dca30c
3
+ size 659677
data/dataset_audio_train_clipped.parquet.gzip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b3fed567b3d361fcfff79ad59a2d45233ef663d965ef17a4d9f42d3bc9662693
3
- size 7864308
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:434345cc785bb9d400d8764edbe413df27c5ade323ce7f4545372f6e7932106c
3
+ size 8172206
data/dataset_audio_validation_clipped.parquet.gzip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f0dfba31f1d0587ebb4b9cbeb96fd10ae93cac9036dc482f4802b1495ab6806c
3
- size 1443196
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58aecf14451ee7a32c6723c9954e79324ff7c937ed8b739eb6f2ff277f9f8285
3
+ size 1482039
speech_commands_enriched.py CHANGED
@@ -229,11 +229,13 @@ class SpeechCommands(datasets.GeneratorBasedBuilder):
229
  # HINT: metadata should already be the split-specific metadata
230
 
231
  pathlist = Path(archive_path).glob('**/*.wav')
 
 
 
232
 
233
  for path, row in zip(pathlist, metadata.iterrows()):
234
 
235
  # row is a tuple containg an index and a pandas series
236
-
237
  pathcomponents = str(path).split("/")
238
  word = pathcomponents[-2]
239
  audio_filename = pathcomponents[-1]
@@ -268,6 +270,6 @@ class SpeechCommands(datasets.GeneratorBasedBuilder):
268
  }
269
 
270
  #for debugging, comment out after
271
- if __name__ == "__main__":
272
- ds = datasets.load_dataset("speech_commands_enriched.py", 'v0.01', split="test",
273
- streaming=False)
 
229
  # HINT: metadata should already be the split-specific metadata
230
 
231
  pathlist = Path(archive_path).glob('**/*.wav')
232
+ # sort _silence_ after all the other paths; aligns metadata to data as data is not sorted by #
233
+ # ascending order
234
+ pathlist = sorted(pathlist, key=lambda d: str(d).lower().replace("_", "{"))
235
 
236
  for path, row in zip(pathlist, metadata.iterrows()):
237
 
238
  # row is a tuple containg an index and a pandas series
 
239
  pathcomponents = str(path).split("/")
240
  word = pathcomponents[-2]
241
  audio_filename = pathcomponents[-1]
 
270
  }
271
 
272
  #for debugging, comment out after
273
+ #if __name__ == "__main__":
274
+ #ds = datasets.load_dataset("speech_commands_enriched.py", 'v0.01', split="test",
275
+ #streaming=False)