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:
@@ -90,10 +90,13 @@ class SeedVCService:
|
|||||||
logger.info(f"Using reference: {reference_audio_path}")
|
logger.info(f"Using reference: {reference_audio_path}")
|
||||||
|
|
||||||
if self.model is None:
|
if self.model is None:
|
||||||
# Fallback: copy source audio
|
# Fallback: convert MP3 to WAV
|
||||||
logger.warning("Seed-VC not available, using passthrough mode")
|
logger.warning("Seed-VC not available, using passthrough mode")
|
||||||
import shutil
|
from pydub import AudioSegment
|
||||||
shutil.copy(source_audio_path, output_path)
|
# 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
|
return output_path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -117,9 +120,12 @@ class SeedVCService:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Voice conversion failed: {e}")
|
logger.error(f"Voice conversion failed: {e}")
|
||||||
# Fallback: copy source audio
|
# Fallback: convert MP3 to WAV
|
||||||
import shutil
|
logger.warning("Fallback to MP3-to-WAV conversion")
|
||||||
shutil.copy(source_audio_path, output_path)
|
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
|
return output_path
|
||||||
|
|
||||||
def preprocess_audio(self, input_path: str, output_path: str, target_sr: int = 22050) -> str:
|
def preprocess_audio(self, input_path: str, output_path: str, target_sr: int = 22050) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user