fix: only catch ImportError in _resample torchaudio fallback
Catching bare Exception was silently swallowing real resampling errors. Only ImportError should trigger the interpolate fallback. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
219c74d7ed
commit
76118f57c3
1 file changed
+1
-1
+1
-1
@@ -17,7 +17,7 @@ def _resample(waveform, src_sr, dst_sr):
|
||||
# Resample expects (channels, samples), not (batch, channels, samples)
|
||||
resampler = torchaudio.transforms.Resample(orig_freq=src_sr, new_freq=dst_sr)
|
||||
return resampler(waveform.squeeze(0)).unsqueeze(0)
|
||||
except Exception:
|
||||
except ImportError:
|
||||
ratio = dst_sr / src_sr
|
||||
new_len = int(waveform.shape[-1] * ratio)
|
||||
return torch.nn.functional.interpolate(
|
||||
|
||||
Reference in new issue
Block a user