From a63d80f9aa6dbdbf7319a7ccfb0eba974b956e63 Mon Sep 17 00:00:00 2001 From: Jael Gu Date: Mon, 13 Feb 2023 15:59:58 +0800 Subject: [PATCH] Fix for stereo audio Signed-off-by: Jael Gu --- panns.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/panns.py b/panns.py index 76635bb..e79c671 100644 --- a/panns.py +++ b/panns.py @@ -74,7 +74,8 @@ class Panns(NNOperator): resampler = torchaudio.transforms.Resample(sr, self.sample_rate, dtype=audio.dtype) audio = resampler(audio) - audio = audio[None, :] + if len(audio.shape) == 1: + audio = audio[None, :] clipwise_output, embedding = self.tagger.inference(audio) sorted_indexes = numpy.argsort(clipwise_output[0])[::-1]