Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,251 +4,274 @@ import torchaudio
|
|
| 4 |
import tempfile
|
| 5 |
import os
|
| 6 |
import warnings
|
|
|
|
| 7 |
|
| 8 |
warnings.filterwarnings("ignore")
|
| 9 |
|
| 10 |
# CRITICAL: Coqui Terms of Service
|
| 11 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 12 |
|
| 13 |
-
print("๐ Starting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Device setup
|
| 16 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 17 |
print(f"๐ Using device: {DEVICE}")
|
| 18 |
|
| 19 |
-
# Global
|
| 20 |
TTS_MODEL = None
|
| 21 |
WHISPER_MODEL = None
|
|
|
|
| 22 |
|
| 23 |
-
def
|
| 24 |
-
"""Load
|
| 25 |
-
global TTS_MODEL
|
| 26 |
|
| 27 |
-
if TTS_MODEL is not None:
|
| 28 |
return True
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
# Use a simpler model that doesn't have the XTTS issues
|
| 35 |
-
TTS_MODEL = TTS(
|
| 36 |
-
model_name="tts_models/en/vctk/vits",
|
| 37 |
-
progress_bar=True,
|
| 38 |
-
gpu=(DEVICE == "cuda")
|
| 39 |
-
)
|
| 40 |
-
|
| 41 |
-
print("โ
Simple TTS model loaded successfully!")
|
| 42 |
-
return True
|
| 43 |
-
|
| 44 |
-
except Exception as e:
|
| 45 |
-
print(f"โ Simple TTS failed: {e}")
|
| 46 |
-
|
| 47 |
-
# Ultimate fallback - use the most basic model
|
| 48 |
try:
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
| 59 |
return False
|
| 60 |
-
|
| 61 |
-
def load_whisper():
|
| 62 |
-
"""Load Whisper for transcription"""
|
| 63 |
-
global WHISPER_MODEL
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
-
import whisper
|
| 70 |
-
WHISPER_MODEL = whisper.load_model("base")
|
| 71 |
-
print("โ
Whisper loaded!")
|
| 72 |
-
return True
|
| 73 |
-
except Exception as e:
|
| 74 |
-
print(f"โ Whisper failed: {e}")
|
| 75 |
-
return False
|
| 76 |
|
| 77 |
-
def
|
| 78 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
try:
|
| 80 |
-
|
| 81 |
-
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
return None, "โ TTS model failed to load!"
|
| 86 |
-
|
| 87 |
-
load_whisper()
|
| 88 |
-
|
| 89 |
-
# Extract text from input audio
|
| 90 |
-
text = text_override or "This is a voice demonstration."
|
| 91 |
-
if WHISPER_MODEL and not text_override:
|
| 92 |
-
try:
|
| 93 |
-
result = WHISPER_MODEL.transcribe(input_audio)
|
| 94 |
-
extracted = result.get("text", "").strip()
|
| 95 |
-
if extracted and len(extracted) > 3:
|
| 96 |
-
text = extracted
|
| 97 |
-
print(f"โ
Extracted: {text[:50]}...")
|
| 98 |
-
except Exception as e:
|
| 99 |
-
print(f"โ ๏ธ Whisper error: {e}")
|
| 100 |
|
| 101 |
-
|
| 102 |
-
print(f"๐ญ Generating speech: {text[:50]}...")
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
|
|
|
| 106 |
|
| 107 |
-
#
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
file_path=output_path
|
| 111 |
-
)
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
return None, "โ Output file is empty!"
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
# Load models
|
| 128 |
-
if not load_simple_tts():
|
| 129 |
-
return None, "โ TTS model failed to load!"
|
| 130 |
|
| 131 |
-
|
|
|
|
| 132 |
|
| 133 |
-
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as
|
| 134 |
-
output_path =
|
| 135 |
|
| 136 |
-
#
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
| 141 |
|
|
|
|
| 142 |
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
|
| 143 |
-
return output_path, f"โ
SUCCESS!\n\n
|
| 144 |
else:
|
| 145 |
-
return None, "โ
|
| 146 |
|
| 147 |
except Exception as e:
|
| 148 |
-
return None, f"โ Error: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
# Create Gradio Interface
|
| 151 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
gr.HTML("""
|
| 154 |
<div style="text-align: center; padding: 20px;">
|
| 155 |
-
<h1>๐ญ
|
| 156 |
-
<p style="color: #
|
| 157 |
-
<p style="color: #
|
| 158 |
</div>
|
| 159 |
""")
|
| 160 |
|
| 161 |
-
#
|
| 162 |
-
gr.HTML("""
|
| 163 |
-
<div style="
|
| 164 |
-
<
|
| 165 |
-
<p><strong>Problem:</strong> XTTS-v2 has multiple complex loading issues</p>
|
| 166 |
-
<p><strong>Solution:</strong> Use simpler TTS models that work reliably</p>
|
| 167 |
-
<p><strong>Result:</strong> No more path errors, generate errors, or loading failures!</p>
|
| 168 |
</div>
|
| 169 |
""")
|
| 170 |
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
<li>
|
|
|
|
| 180 |
</ul>
|
| 181 |
</div>
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
type="filepath",
|
| 187 |
sources=["upload", "microphone"]
|
| 188 |
)
|
| 189 |
|
| 190 |
-
|
| 191 |
-
label="
|
| 192 |
-
|
| 193 |
-
|
| 194 |
)
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
)
|
| 205 |
-
|
| 206 |
-
with gr.TabItem("๐ Text-to-Speech"):
|
| 207 |
-
gr.HTML("""
|
| 208 |
-
<div style="padding: 15px; background: #f0fff0; border-radius: 10px; margin-bottom: 15px;">
|
| 209 |
-
<h4 style="color: #16a34a;">๐ Simple Text-to-Speech:</h4>
|
| 210 |
-
<ul>
|
| 211 |
-
<li>Enter any text to convert to speech</li>
|
| 212 |
-
<li>Uses reliable TTS model</li>
|
| 213 |
-
<li>No complex loading or path issues!</li>
|
| 214 |
-
</ul>
|
| 215 |
-
</div>
|
| 216 |
-
""")
|
| 217 |
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
)
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
inputs=[text_input],
|
| 231 |
-
outputs=[output2, status2]
|
| 232 |
)
|
| 233 |
|
| 234 |
-
#
|
| 235 |
-
gr.
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
if __name__ == "__main__":
|
| 254 |
demo.launch()
|
|
|
|
| 4 |
import tempfile
|
| 5 |
import os
|
| 6 |
import warnings
|
| 7 |
+
from contextlib import contextmanager
|
| 8 |
|
| 9 |
warnings.filterwarnings("ignore")
|
| 10 |
|
| 11 |
# CRITICAL: Coqui Terms of Service
|
| 12 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 13 |
|
| 14 |
+
print("๐ Starting Voice-to-Voice Cloning Studio...")
|
| 15 |
+
|
| 16 |
+
# PyTorch 2.6 Compatibility Fix
|
| 17 |
+
@contextmanager
|
| 18 |
+
def patch_torch_load():
|
| 19 |
+
"""Fix PyTorch 2.6 weights_only issue"""
|
| 20 |
+
original_load = torch.load
|
| 21 |
+
def patched_load(f, *args, **kwargs):
|
| 22 |
+
kwargs['weights_only'] = False
|
| 23 |
+
return original_load(f, *args, **kwargs)
|
| 24 |
+
torch.load = patched_load
|
| 25 |
+
try:
|
| 26 |
+
yield
|
| 27 |
+
finally:
|
| 28 |
+
torch.load = original_load
|
| 29 |
|
| 30 |
# Device setup
|
| 31 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 32 |
print(f"๐ Using device: {DEVICE}")
|
| 33 |
|
| 34 |
+
# Global models
|
| 35 |
TTS_MODEL = None
|
| 36 |
WHISPER_MODEL = None
|
| 37 |
+
MODEL_STATUS = "Not Loaded"
|
| 38 |
|
| 39 |
+
def load_voice_cloning_models():
|
| 40 |
+
"""Load models for voice-to-voice cloning"""
|
| 41 |
+
global TTS_MODEL, WHISPER_MODEL, MODEL_STATUS
|
| 42 |
|
| 43 |
+
if TTS_MODEL is not None and WHISPER_MODEL is not None:
|
| 44 |
return True
|
| 45 |
|
| 46 |
+
print("๐ Loading voice cloning models...")
|
| 47 |
+
|
| 48 |
+
# Load XTTS for voice cloning
|
| 49 |
+
if TTS_MODEL is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
try:
|
| 51 |
+
with patch_torch_load():
|
| 52 |
+
from TTS.api import TTS
|
| 53 |
+
print("๐ฆ Loading XTTS for voice cloning...")
|
| 54 |
+
TTS_MODEL = TTS(
|
| 55 |
+
model_name="tts_models/multilingual/multi-dataset/xtts_v2",
|
| 56 |
+
progress_bar=True,
|
| 57 |
+
gpu=(DEVICE == "cuda")
|
| 58 |
+
)
|
| 59 |
+
MODEL_STATUS = "XTTS-v2 Ready"
|
| 60 |
+
print("โ
XTTS voice cloning model loaded!")
|
| 61 |
+
except Exception as e:
|
| 62 |
+
print(f"โ XTTS loading failed: {e}")
|
| 63 |
+
MODEL_STATUS = f"XTTS Failed: {str(e)}"
|
| 64 |
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
# Load Whisper for speech-to-text
|
| 67 |
+
if WHISPER_MODEL is None:
|
| 68 |
+
try:
|
| 69 |
+
import whisper
|
| 70 |
+
print("๐ฆ Loading Whisper for speech recognition...")
|
| 71 |
+
WHISPER_MODEL = whisper.load_model("base")
|
| 72 |
+
print("โ
Whisper loaded!")
|
| 73 |
+
except Exception as e:
|
| 74 |
+
print(f"โ Whisper loading failed: {e}")
|
| 75 |
+
return False
|
| 76 |
|
| 77 |
+
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
def voice_to_voice_clone(reference_audio, input_audio, language="en"):
|
| 80 |
+
"""
|
| 81 |
+
REAL Voice-to-Voice Cloning Function
|
| 82 |
+
Input: Reference voice + Input audio content
|
| 83 |
+
Output: Input content spoken in reference voice
|
| 84 |
+
"""
|
| 85 |
try:
|
| 86 |
+
# Input validation
|
| 87 |
+
if not reference_audio:
|
| 88 |
+
return None, "โ Please upload REFERENCE AUDIO (voice to clone)!"
|
| 89 |
|
| 90 |
+
if not input_audio:
|
| 91 |
+
return None, "โ Please upload INPUT AUDIO (content to transform)!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
print("๐ค Starting Voice-to-Voice Cloning Process...")
|
|
|
|
| 94 |
|
| 95 |
+
# Load models
|
| 96 |
+
if not load_voice_cloning_models():
|
| 97 |
+
return None, f"โ Model loading failed!\nStatus: {MODEL_STATUS}\n\nTry restarting the space."
|
| 98 |
|
| 99 |
+
# STEP 1: Extract text from input audio using Whisper
|
| 100 |
+
print("๐ Step 1: Extracting text from input audio...")
|
| 101 |
+
extracted_text = ""
|
|
|
|
|
|
|
| 102 |
|
| 103 |
+
try:
|
| 104 |
+
result = WHISPER_MODEL.transcribe(input_audio)
|
| 105 |
+
extracted_text = result.get("text", "").strip()
|
|
|
|
| 106 |
|
| 107 |
+
if not extracted_text or len(extracted_text) < 3:
|
| 108 |
+
extracted_text = "Voice cloning demonstration using the uploaded audio content."
|
| 109 |
+
|
| 110 |
+
print(f"โ
Extracted text: '{extracted_text[:100]}...'")
|
| 111 |
+
|
| 112 |
+
except Exception as e:
|
| 113 |
+
print(f"โ ๏ธ Whisper extraction failed: {e}")
|
| 114 |
+
extracted_text = "Voice cloning demonstration using the uploaded audio content."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
# STEP 2: Generate new audio using reference voice + extracted text
|
| 117 |
+
print("๐ญ Step 2: Generating speech with reference voice...")
|
| 118 |
|
| 119 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp_file:
|
| 120 |
+
output_path = tmp_file.name
|
| 121 |
|
| 122 |
+
# Use XTTS for voice cloning
|
| 123 |
+
with patch_torch_load():
|
| 124 |
+
TTS_MODEL.tts_to_file(
|
| 125 |
+
text=extracted_text,
|
| 126 |
+
speaker_wav=reference_audio,
|
| 127 |
+
language=language,
|
| 128 |
+
file_path=output_path
|
| 129 |
+
)
|
| 130 |
|
| 131 |
+
# Verify output
|
| 132 |
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
|
| 133 |
+
return output_path, f"โ
VOICE-TO-VOICE CLONING SUCCESS!\n\n๐ค **Process Completed:**\nโข Extracted content: '{extracted_text[:150]}...'\nโข Applied reference voice characteristics\nโข Generated NEW audio with cloned voice\n\n๐ Language: {language}\n๐ค Model: {MODEL_STATUS}\n๐ญ This is REAL voice cloning - same content, different voice!"
|
| 134 |
else:
|
| 135 |
+
return None, "โ Generated audio file is empty!"
|
| 136 |
|
| 137 |
except Exception as e:
|
| 138 |
+
return None, f"โ Voice-to-Voice Cloning Error: {str(e)}\n\nModel Status: {MODEL_STATUS}"
|
| 139 |
+
|
| 140 |
+
# Initialize models at startup
|
| 141 |
+
print("๐ Initializing voice cloning models...")
|
| 142 |
+
try:
|
| 143 |
+
startup_success = load_voice_cloning_models()
|
| 144 |
+
if startup_success:
|
| 145 |
+
startup_msg = f"โ
{MODEL_STATUS} - Voice Cloning Ready!"
|
| 146 |
+
startup_color = "#d4edda"
|
| 147 |
+
else:
|
| 148 |
+
startup_msg = f"โ ๏ธ Models will load on first use - {MODEL_STATUS}"
|
| 149 |
+
startup_color = "#fff3cd"
|
| 150 |
+
except Exception as e:
|
| 151 |
+
startup_success = False
|
| 152 |
+
startup_msg = f"โ ๏ธ Startup issue: {str(e)}"
|
| 153 |
+
startup_color = "#f8d7da"
|
| 154 |
+
|
| 155 |
+
print(f"Startup status: {startup_msg}")
|
| 156 |
|
| 157 |
# Create Gradio Interface
|
| 158 |
+
with gr.Blocks(
|
| 159 |
+
title="๐ญ Voice-to-Voice Cloning Studio",
|
| 160 |
+
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="green")
|
| 161 |
+
) as demo:
|
| 162 |
|
| 163 |
gr.HTML("""
|
| 164 |
<div style="text-align: center; padding: 20px;">
|
| 165 |
+
<h1 style="color: #2E86AB;">๐ญ Voice-to-Voice Cloning Studio</h1>
|
| 166 |
+
<p style="color: #666; font-size: 18px;">REAL Voice-to-Voice Cloning - Transform Any Voice!</p>
|
| 167 |
+
<p style="color: #888; font-size: 14px;">Extract content from input audio โ Generate with reference voice</p>
|
| 168 |
</div>
|
| 169 |
""")
|
| 170 |
|
| 171 |
+
# Status display
|
| 172 |
+
gr.HTML(f"""
|
| 173 |
+
<div style="text-align: center; padding: 15px; background: {startup_color}; border-radius: 10px; margin-bottom: 20px;">
|
| 174 |
+
<strong>๐ค System Status:</strong> {startup_msg}
|
|
|
|
|
|
|
|
|
|
| 175 |
</div>
|
| 176 |
""")
|
| 177 |
|
| 178 |
+
# How it works
|
| 179 |
+
gr.HTML("""
|
| 180 |
+
<div style="padding: 20px; background: #e8f4fd; border-radius: 10px; margin-bottom: 20px;">
|
| 181 |
+
<h4 style="color: #1e40af; margin-bottom: 15px;">๐ค How Voice-to-Voice Cloning Works:</h4>
|
| 182 |
+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
|
| 183 |
+
<div>
|
| 184 |
+
<h5>๐ฅ Inputs Required:</h5>
|
| 185 |
+
<ul style="margin: 5px 0; padding-left: 20px;">
|
| 186 |
+
<li><strong>Reference Audio:</strong> Voice to clone (6+ seconds)</li>
|
| 187 |
+
<li><strong>Input Audio:</strong> Content to transform</li>
|
| 188 |
</ul>
|
| 189 |
</div>
|
| 190 |
+
<div>
|
| 191 |
+
<h5>โ๏ธ Process:</h5>
|
| 192 |
+
<ul style="margin: 5px 0; padding-left: 20px;">
|
| 193 |
+
<li>Extract text from input audio</li>
|
| 194 |
+
<li>Generate new speech with reference voice</li>
|
| 195 |
+
</ul>
|
| 196 |
+
</div>
|
| 197 |
+
</div>
|
| 198 |
+
<h5>๐ฏ Result: Same content, different voice (REAL voice cloning!)</h5>
|
| 199 |
+
</div>
|
| 200 |
+
""")
|
| 201 |
+
|
| 202 |
+
# Main interface
|
| 203 |
+
with gr.Row():
|
| 204 |
+
with gr.Column():
|
| 205 |
+
reference_audio = gr.Audio(
|
| 206 |
+
label="๐ค Reference Audio (Voice to Clone)",
|
| 207 |
type="filepath",
|
| 208 |
sources=["upload", "microphone"]
|
| 209 |
)
|
| 210 |
|
| 211 |
+
input_audio = gr.Audio(
|
| 212 |
+
label="๐ต Input Audio (Content to Transform)",
|
| 213 |
+
type="filepath",
|
| 214 |
+
sources=["upload", "microphone"]
|
| 215 |
)
|
| 216 |
|
| 217 |
+
language = gr.Dropdown(
|
| 218 |
+
choices=[
|
| 219 |
+
("๐บ๐ธ English", "en"),
|
| 220 |
+
("๐ช๐ธ Spanish", "es"),
|
| 221 |
+
("๐ซ๐ท French", "fr"),
|
| 222 |
+
("๐ฉ๐ช German", "de"),
|
| 223 |
+
("๐ฎ๐น Italian", "it"),
|
| 224 |
+
("๐ง๐ท Portuguese", "pt"),
|
| 225 |
+
("๐จ๐ณ Chinese", "zh"),
|
| 226 |
+
("๐ฏ๐ต Japanese", "ja")
|
| 227 |
+
],
|
| 228 |
+
value="en",
|
| 229 |
+
label="Language"
|
| 230 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
+
clone_btn = gr.Button(
|
| 233 |
+
"๐ญ Clone Voice (Voice-to-Voice)",
|
| 234 |
+
variant="primary",
|
| 235 |
+
size="lg"
|
| 236 |
)
|
| 237 |
+
|
| 238 |
+
with gr.Column():
|
| 239 |
+
output_audio = gr.Audio(label="๐ Cloned Voice Result")
|
| 240 |
+
status_output = gr.Textbox(
|
| 241 |
+
label="Processing Status & Details",
|
| 242 |
+
lines=12,
|
| 243 |
+
interactive=False
|
|
|
|
|
|
|
| 244 |
)
|
| 245 |
|
| 246 |
+
# Examples
|
| 247 |
+
with gr.Accordion("๐ก Example Usage", open=False):
|
| 248 |
+
gr.Markdown("""
|
| 249 |
+
### ๐ฏ Perfect Use Cases:
|
| 250 |
+
- **Voice Acting**: Transform your voice to sound like someone else
|
| 251 |
+
- **Content Creation**: Make podcasts in different voices
|
| 252 |
+
- **Language Learning**: Hear text in your target accent
|
| 253 |
+
- **Accessibility**: Convert speech to preferred voice characteristics
|
| 254 |
|
| 255 |
+
### ๐ Step-by-Step:
|
| 256 |
+
1. **Upload Reference Audio**: 6+ seconds of the voice you want to clone
|
| 257 |
+
2. **Upload Input Audio**: Speech content you want to transform
|
| 258 |
+
3. **Select Language**: Choose the language of the content
|
| 259 |
+
4. **Click Clone Voice**: Wait for processing (30-60 seconds)
|
| 260 |
+
5. **Download Result**: New audio with same content, different voice!
|
| 261 |
+
|
| 262 |
+
### ๐ Example:
|
| 263 |
+
- **Reference**: Morgan Freeman speaking
|
| 264 |
+
- **Input**: Your voice saying "Hello world"
|
| 265 |
+
- **Result**: "Hello world" in Morgan Freeman's voice style
|
| 266 |
+
""")
|
| 267 |
+
|
| 268 |
+
# Event handler
|
| 269 |
+
clone_btn.click(
|
| 270 |
+
fn=voice_to_voice_clone,
|
| 271 |
+
inputs=[reference_audio, input_audio, language],
|
| 272 |
+
outputs=[output_audio, status_output],
|
| 273 |
+
show_progress=True
|
| 274 |
+
)
|
| 275 |
|
| 276 |
if __name__ == "__main__":
|
| 277 |
demo.launch()
|