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
-1
@@ -17,7 +17,7 @@ def _resample(waveform, src_sr, dst_sr):
|
|||||||
# Resample expects (channels, samples), not (batch, channels, samples)
|
# Resample expects (channels, samples), not (batch, channels, samples)
|
||||||
resampler = torchaudio.transforms.Resample(orig_freq=src_sr, new_freq=dst_sr)
|
resampler = torchaudio.transforms.Resample(orig_freq=src_sr, new_freq=dst_sr)
|
||||||
return resampler(waveform.squeeze(0)).unsqueeze(0)
|
return resampler(waveform.squeeze(0)).unsqueeze(0)
|
||||||
except Exception:
|
except ImportError:
|
||||||
ratio = dst_sr / src_sr
|
ratio = dst_sr / src_sr
|
||||||
new_len = int(waveform.shape[-1] * ratio)
|
new_len = int(waveform.shape[-1] * ratio)
|
||||||
return torch.nn.functional.interpolate(
|
return torch.nn.functional.interpolate(
|
||||||
|
|||||||
Reference in New Issue
Block a user