From 45946a5b70131bc257ac5fd13db9e130cc5890a2 Mon Sep 17 00:00:00 2001 From: NextFire Date: Sat, 23 Nov 2024 17:42:34 +0100 Subject: [PATCH] fix: torchaudio.load/save use .as_posix() "sox_io backend does not handle file-like object" --- yohane-cli/yohane_cli/audio.py | 4 ++-- yohane/pipeline.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/yohane-cli/yohane_cli/audio.py b/yohane-cli/yohane_cli/audio.py index ea634725..97b311be 100644 --- a/yohane-cli/yohane_cli/audio.py +++ b/yohane-cli/yohane_cli/audio.py @@ -65,9 +65,9 @@ def save_separated_tracks(yohane: Yohane, song_path: Path): waveform, sample_rate = yohane.vocals filename = song_path.with_suffix(".vocals.wav") logger.info(f"Saving vocals track to {filename}") - torchaudio.save(filename, waveform.to("cpu"), sample_rate) + torchaudio.save(filename.as_posix(), waveform.to("cpu"), sample_rate) if yohane.off_vocal is not None: waveform, sample_rate = yohane.off_vocal filename = song_path.with_suffix(".off_vocal.wav") logger.info(f"Saving off vocal track to {filename}") - torchaudio.save(filename, waveform.to("cpu"), sample_rate) + torchaudio.save(filename.as_posix(), waveform.to("cpu"), sample_rate) diff --git a/yohane/pipeline.py b/yohane/pipeline.py index 6a4c6a3c..389946ae 100644 --- a/yohane/pipeline.py +++ b/yohane/pipeline.py @@ -36,7 +36,7 @@ def off_vocal(self): def load_song(self, song_file: Path): logger.info("Loading song") - self.song = torchaudio.load(song_file) + self.song = torchaudio.load(song_file.as_posix()) def extract_vocals(self): if self.separator is not None: