Skip to content

Commit

Permalink
OggZipDataset, support freeing resources
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Jan 18, 2024
1 parent ca90f08 commit e8c0fee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion returnn/datasets/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def __init__(
# Special case (mostly for debugging) to directly access the filesystem, not via zip-file.
self.paths = [os.path.dirname(path)]
self._names = [os.path.basename(path)]
self._zip_files = None
self._use_zip_files = False
assert not use_cache_manager, "cache manager only for zip file"
else:
Expand Down Expand Up @@ -250,6 +249,17 @@ def _lazy_init(self):

self._data = data

def finish_epoch(self, *, free_resources: bool = False):
"""finish epoch"""
super().finish_epoch()
self._seq_order = None
self._num_seqs = 0
if free_resources:
# Basically undo the _lazy_init, such that _lazy_init would init again next time.
self._data = None
self.segments = None
self._zip_files = None

def _read_segment_list(self, segment_file):
"""
read a list of segment names in either plain text or gzip
Expand Down

0 comments on commit e8c0fee

Please sign in to comment.