Commit 9da92cdb authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Fix path normalization for StreamWriter-based save operation (#3248)

Summary:
Follow up of https://github.com/pytorch/audio/issues/3243. Save compat module had different semantics than info and load, which requires different way of performing path normalization.

Pull Request resolved: https://github.com/pytorch/audio/pull/3248

Reviewed By: hwangjeff

Differential Revision: D44774997

Pulled By: mthrok

fbshipit-source-id: 4b967ae3ca6b45850d455b8e95aaa31762c5457e
parent ae614ed3
...@@ -122,7 +122,7 @@ class FFmpegBackend(Backend): ...@@ -122,7 +122,7 @@ class FFmpegBackend(Backend):
buffer_size: int = 4096, buffer_size: int = 4096,
) -> None: ) -> None:
save_audio( save_audio(
os.path.normpath(uri), uri,
src, src,
sample_rate, sample_rate,
channels_first, channels_first,
......
...@@ -204,8 +204,11 @@ def save_audio( ...@@ -204,8 +204,11 @@ def save_audio(
bits_per_sample: Optional[int] = None, bits_per_sample: Optional[int] = None,
buffer_size: int = 4096, buffer_size: int = 4096,
) -> None: ) -> None:
if hasattr(uri, "write") and format is None: if hasattr(uri, "write"):
raise RuntimeError("'format' is required when saving to file object.") if format is None:
raise RuntimeError("'format' is required when saving to file object.")
else:
uri = os.path.normpath(uri)
s = StreamWriter(uri, format=format, buffer_size=buffer_size) s = StreamWriter(uri, format=format, buffer_size=buffer_size)
if format is None: if format is None:
tokens = str(uri).split(".") tokens = str(uri).split(".")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment