fix: passthrough mode MP3 to WAV conversion

- Use pydub to convert MP3 to WAV in passthrough mode
- Fixed fallback conversion when Seed-VC is not available
- Output WAV format as expected by the API
This commit is contained in:
Azimkin
2026-04-08 02:07:16 +02:00
parent ad844e986a
commit 263bc3e54c

View File

@@ -90,10 +90,13 @@ class SeedVCService:
logger.info(f"Using reference: {reference_audio_path}")
if self.model is None:
# Fallback: copy source audio
# Fallback: convert MP3 to WAV
logger.warning("Seed-VC not available, using passthrough mode")
import shutil
shutil.copy(source_audio_path, output_path)
from pydub import AudioSegment
# Load MP3 and convert to WAV
audio = AudioSegment.from_mp3(source_audio_path)
audio.export(output_path, format="wav")
logger.info(f"MP3 to WAV conversion complete: {output_path}")
return output_path
try:
@@ -117,9 +120,12 @@ class SeedVCService:
except Exception as e:
logger.error(f"Voice conversion failed: {e}")
# Fallback: copy source audio
import shutil
shutil.copy(source_audio_path, output_path)
# Fallback: convert MP3 to WAV
logger.warning("Fallback to MP3-to-WAV conversion")
from pydub import AudioSegment
audio = AudioSegment.from_mp3(source_audio_path)
audio.export(output_path, format="wav")
logger.info(f"MP3 to WAV conversion complete: {output_path}")
return output_path
def preprocess_audio(self, input_path: str, output_path: str, target_sr: int = 22050) -> str: