Skip to content

Commit

Permalink
create output dirs before writing data
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthier BERTHOMIEU committed Dec 17, 2024
1 parent 1998e52 commit 6f27ac2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/OSmOSE/data/audio_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def write(self, folder: Path) -> None:
Folder in which to write the audio file.
"""
super().write(path=folder)
sf.write(folder / f"{self}.wav", self.get_value(), self.sample_rate)

def _get_item_value(self, item: AudioItem) -> np.ndarray:
Expand Down
10 changes: 7 additions & 3 deletions src/OSmOSE/data/base_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import numpy as np

from OSmOSE.config import DPDEFAULT
from OSmOSE.data.base_file import BaseFile
from OSmOSE.data.base_item import BaseItem
from OSmOSE.data.event import Event
Expand Down Expand Up @@ -67,9 +68,12 @@ def get_value(self) -> np.ndarray:
"""Get the concatenated values from all Items."""
return np.concatenate([item.get_value() for item in self.items])

def write(self, path: Path) -> None: # noqa: ARG002
"""Abstract method for writing the data."""
return
def write(self, path: Path) -> None:
"""Create the directory in which the data will be written.
The actual data writing is left to the specified classes.
"""
path.mkdir(parents=True, exist_ok=True, mode=DPDEFAULT)

@classmethod
def from_files(
Expand Down

0 comments on commit 6f27ac2

Please sign in to comment.