From f1a6db2a2a02c0e80a3073027d1ae9b49d45b3c1 Mon Sep 17 00:00:00 2001 From: Purfview <69023953+Purfview@users.noreply.github.com> Date: Fri, 17 May 2024 20:03:32 +0100 Subject: [PATCH] fix(doc): remove mention of unsupported `numpy.ndarray` waveform (#1691) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hervé BREDIN --- CHANGELOG.md | 1 + pyannote/audio/core/io.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index accc0cc1b..064242ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - fix(task): fix estimation of training set size (with [@FrenchKrab](https://github.com/FrenchKrab)) - fix(hook): fix `torch.Tensor` support in `ArtifactHook` - fix(doc): fix typo in `Powerset` docstring (with [@lukasstorck](https://github.com/lukasstorck)) +- fix(doc): remove mention of unsupported `numpy.ndarray` waveform (with [@Purfview](https://github.com/Purfview)) ### Improvements diff --git a/pyannote/audio/core/io.py b/pyannote/audio/core/io.py index bce9c4dbf..352824737 100644 --- a/pyannote/audio/core/io.py +++ b/pyannote/audio/core/io.py @@ -48,7 +48,7 @@ - a "IOBase" instance with "read" and "seek" support: open("audio.wav", "rb") - a "Mapping" with any of the above as "audio" key: {"audio": ...} - a "Mapping" with both "waveform" and "sample_rate" key: - {"waveform": (channel, time) numpy.ndarray or torch.Tensor, "sample_rate": 44100} + {"waveform": (channel, time) torch.Tensor, "sample_rate": 44100} For last two options, an additional "channel" key can be provided as a zero-indexed integer to load a specific channel: {"audio": "stereo.wav", "channel": 0} @@ -149,7 +149,7 @@ def validate_file(file: AudioFile) -> Mapping: ------- validated_file : Mapping {"audio": str, "uri": str, ...} - {"waveform": array or tensor, "sample_rate": int, "uri": str, ...} + {"waveform": tensor, "sample_rate": int, "uri": str, ...} {"audio": file, "uri": "stream"} if `file` is an IOBase instance Raises @@ -171,7 +171,7 @@ def validate_file(file: AudioFile) -> Mapping: raise ValueError(AudioFileDocString) if "waveform" in file: - waveform: Union[np.ndarray, Tensor] = file["waveform"] + waveform: Tensor = file["waveform"] if len(waveform.shape) != 2 or waveform.shape[0] > waveform.shape[1]: raise ValueError( "'waveform' must be provided as a (channel, time) torch Tensor."