Spaces:
Sleeping
Sleeping
Fix: replace torchaudio.load with soundfile.read to avoid torchcodec dependency error
Browse files
app.py
CHANGED
|
@@ -325,11 +325,11 @@ class VoiceCloner:
|
|
| 325 |
self._ensure_hifigan()
|
| 326 |
|
| 327 |
try:
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
if sr != self.sample_rate:
|
| 334 |
y = torchaudio.transforms.Resample(sr, self.sample_rate)(y)
|
| 335 |
sr = self.sample_rate
|
|
|
|
| 325 |
self._ensure_hifigan()
|
| 326 |
|
| 327 |
try:
|
| 328 |
+
# Use soundfile directly to avoid torchaudio torchcodec backend issues
|
| 329 |
+
audio_data, sr = sf.read(input_audio, dtype='float32')
|
| 330 |
+
if audio_data.ndim > 1:
|
| 331 |
+
audio_data = audio_data.mean(axis=1)
|
| 332 |
+
y = torch.from_numpy(audio_data)
|
| 333 |
if sr != self.sample_rate:
|
| 334 |
y = torchaudio.transforms.Resample(sr, self.sample_rate)(y)
|
| 335 |
sr = self.sample_rate
|