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

Support writing opus and mp3 with soundfile (#3554)

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

Reviewed By: huangruizhe

Differential Revision: D48240906

Pulled By: mthrok

fbshipit-source-id: 1936757646f8ebba74e8b65e2ffe2a8b74fdfeeb
parent 1e6a8f93
...@@ -305,9 +305,15 @@ def _get_subtype(dtype: torch.dtype, format: str, encoding: str, bits_per_sample ...@@ -305,9 +305,15 @@ def _get_subtype(dtype: torch.dtype, format: str, encoding: str, bits_per_sample
raise ValueError("flac does not support bits_per_sample > 24.") raise ValueError("flac does not support bits_per_sample > 24.")
return "PCM_S8" if bits_per_sample == 8 else f"PCM_{bits_per_sample}" return "PCM_S8" if bits_per_sample == 8 else f"PCM_{bits_per_sample}"
if format in ("ogg", "vorbis"): if format in ("ogg", "vorbis"):
if encoding or bits_per_sample: if bits_per_sample:
raise ValueError("ogg/vorbis does not support encoding/bits_per_sample.") raise ValueError("ogg/vorbis does not support bits_per_sample.")
return "VORBIS" if encoding is None or encoding == "vorbis":
return "VORBIS"
if encoding == "opus":
return "OPUS"
raise ValueError(f"Unexpected encoding: {encoding}")
if format == "mp3":
return "MPEG_LAYER_III"
if format == "sph": if format == "sph":
return _get_subtype_for_sphere(encoding, bits_per_sample) return _get_subtype_for_sphere(encoding, bits_per_sample)
if format in ("nis", "nist"): if format in ("nis", "nist"):
......
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