Spaces:
Running
Running
handle audio with different shapes
Browse files
app.py
CHANGED
@@ -20,14 +20,11 @@ def denoise(model_name, inputs):
|
|
20 |
else:
|
21 |
model = WaveUNetModel.from_pretrained(model_name)
|
22 |
sr, audio = inputs
|
23 |
-
audio = torch.from_numpy(audio)
|
24 |
-
|
25 |
audio = audio / 32768.0
|
26 |
|
27 |
-
if audio.ndim ==
|
28 |
-
audio = audio.
|
29 |
-
else:
|
30 |
-
audio = audio.permute(0, 2, 1)
|
31 |
|
32 |
print(f"Audio shape: {audio.shape}")
|
33 |
print(f"Sample rate: {sr}")
|
|
|
20 |
else:
|
21 |
model = WaveUNetModel.from_pretrained(model_name)
|
22 |
sr, audio = inputs
|
23 |
+
audio = torch.from_numpy(audio)
|
|
|
24 |
audio = audio / 32768.0
|
25 |
|
26 |
+
if audio.ndim == 1:
|
27 |
+
audio = audio.unsqueeze(0)
|
|
|
|
|
28 |
|
29 |
print(f"Audio shape: {audio.shape}")
|
30 |
print(f"Sample rate: {sr}")
|