scripts/evals: create recording subdirectories when saving audio
Example files can live under subdirectories (e.g. foundational/01.py), so the recording path needs its parent directory created before the audio file is written.
This commit is contained in:
@@ -171,6 +171,7 @@ class EvalRunner:
|
|||||||
async def save_audio(self, name: str, audio: bytes, sample_rate: int, num_channels: int):
|
async def save_audio(self, name: str, audio: bytes, sample_rate: int, num_channels: int):
|
||||||
if len(audio) > 0:
|
if len(audio) > 0:
|
||||||
filename = self._recording_file_name(name)
|
filename = self._recording_file_name(name)
|
||||||
|
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
||||||
logger.debug(f"Saving {name} audio to {filename}")
|
logger.debug(f"Saving {name} audio to {filename}")
|
||||||
with io.BytesIO() as buffer:
|
with io.BytesIO() as buffer:
|
||||||
with wave.open(buffer, "wb") as wf:
|
with wave.open(buffer, "wb") as wf:
|
||||||
|
|||||||
Reference in New Issue
Block a user