sps44 commited on
Commit
fe76bcc
1 Parent(s): 5c8bf8c

streaming flag

Browse files
Files changed (1) hide show
  1. dcase23-task2-enriched.py +4 -2
dcase23-task2-enriched.py CHANGED
@@ -419,6 +419,7 @@ class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
419
  "audio_files": dl_manager.iter_archive(audio_path[split]),
420
  "embeddings": embeddings[split],
421
  "metadata_file": dl_manager.download_and_extract(self.config.data_urls["metadata"]),
 
422
  },
423
  ) for split in split_type if split in self.config.splits
424
  ]
@@ -430,6 +431,7 @@ class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
430
  audio_files: Optional[Iterable],
431
  embeddings: Optional[Dict],
432
  metadata_file: Optional[str],
 
433
  ):
434
  """Yields examples."""
435
  metadata = pd.read_csv(metadata_file)
@@ -440,10 +442,10 @@ class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
440
  lookup = Path(path).parent.name + "/" + Path(path).name
441
  if lookup in metadata["path"].values:
442
  path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
443
- if local_extracted_archive:
444
  audio = {"path": path, "bytes": f.read()}
445
  else:
446
- audio = {"path": path, "bytes": f.read()}
447
  result = {field: None for field in data_fields}
448
  result.update(metadata[metadata["path"] == lookup].T.squeeze().to_dict())
449
  for emb_key in embeddings.keys():
 
419
  "audio_files": dl_manager.iter_archive(audio_path[split]),
420
  "embeddings": embeddings[split],
421
  "metadata_file": dl_manager.download_and_extract(self.config.data_urls["metadata"]),
422
+ "is_streaming": dl_manager.is_streaming,
423
  },
424
  ) for split in split_type if split in self.config.splits
425
  ]
 
431
  audio_files: Optional[Iterable],
432
  embeddings: Optional[Dict],
433
  metadata_file: Optional[str],
434
+ is_streaming: Optional[bool],
435
  ):
436
  """Yields examples."""
437
  metadata = pd.read_csv(metadata_file)
 
442
  lookup = Path(path).parent.name + "/" + Path(path).name
443
  if lookup in metadata["path"].values:
444
  path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
445
+ if is_streaming:
446
  audio = {"path": path, "bytes": f.read()}
447
  else:
448
+ audio = {"path": path, "bytes": None}
449
  result = {field: None for field in data_fields}
450
  result.update(metadata[metadata["path"] == lookup].T.squeeze().to_dict())
451
  for emb_key in embeddings.keys():