Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FreeVC #2451

Merged
merged 10 commits into from
Mar 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Lazy handle for vc
  • Loading branch information
erogol committed Mar 25, 2023
commit a45fbed4d008680b4dc2ca11989dc8cbcceefcb3
7 changes: 5 additions & 2 deletions TTS/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import tempfile

from TTS.utils.audio.numpy_transforms import save_wav
from TTS.utils.manage import ModelManager
Expand Down Expand Up @@ -268,10 +269,12 @@ def tts_with_vc(self, text: str, language: str = None, speaker_wav: str = None):
Path to a reference wav file to use for voice cloning with supporting models like YourTTS.
Defaults to None.
"""
wav = self.tts(text=text, speaker=None, language=language)
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
# Lazy code... save it to a temp file to resample it while reading it for VC
self.tts_to_file(text=text, speaker=None, language=language, file_path=fp.name)
if self.voice_converter is None:
self.load_vc_model_by_name("voice_conversion_models/multilingual/vctk/freevc24")
wav = self.voice_converter.voice_conversion(source_wav=wav, target_wav=speaker_wav)
wav = self.voice_converter.voice_conversion(source_wav=fp.name, target_wav=speaker_wav)
return wav

def tts_with_vc_to_file(
Expand Down