Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -115,9 +115,7 @@ def load_whisper():
|
|
| 115 |
return False
|
| 116 |
|
| 117 |
def voice_to_voice_clone_fixed(reference_audio, input_audio, language="en"):
|
| 118 |
-
"""
|
| 119 |
-
FIXED Voice-to-Voice Cloning - No more generate() errors!
|
| 120 |
-
"""
|
| 121 |
try:
|
| 122 |
if not reference_audio or not input_audio:
|
| 123 |
return None, "β Please upload both reference and input audio files!"
|
|
@@ -226,7 +224,7 @@ except Exception as e:
|
|
| 226 |
startup_msg = f"β οΈ Startup issue: {str(e)}"
|
| 227 |
startup_color = "#f8d7da"
|
| 228 |
|
| 229 |
-
# Create Gradio Interface
|
| 230 |
with gr.Blocks(title="π FIXED Voice Cloning - No Generate() Errors") as demo:
|
| 231 |
|
| 232 |
gr.HTML("""
|
|
@@ -250,11 +248,11 @@ with gr.Blocks(title="π FIXED Voice Cloning - No Generate() Errors") as demo:
|
|
| 250 |
<h4 style="color: #0c5460;">π§ How This Fix Works:</h4>
|
| 251 |
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
|
| 252 |
<div>
|
| 253 |
-
<h5>β Previous
|
| 254 |
<ul>
|
| 255 |
<li><code>'GPT2InferenceModel' object has no attribute 'generate'</code></li>
|
|
|
|
| 256 |
<li>High-level API internally called non-existent method</li>
|
| 257 |
-
<li>TTS package bug causing failures</li>
|
| 258 |
</ul>
|
| 259 |
</div>
|
| 260 |
<div>
|
|
@@ -262,26 +260,26 @@ with gr.Blocks(title="π FIXED Voice Cloning - No Generate() Errors") as demo:
|
|
| 262 |
<ul>
|
| 263 |
<li><strong>Manual Loading:</strong> Direct XTTS model initialization</li>
|
| 264 |
<li><strong>Direct Inference:</strong> Uses <code>model.inference()</code> not generate()</li>
|
| 265 |
-
<li><strong>
|
| 266 |
</ul>
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
</div>
|
| 270 |
""")
|
| 271 |
|
| 272 |
-
# Main interface
|
| 273 |
with gr.Row():
|
| 274 |
with gr.Column():
|
| 275 |
reference_audio = gr.Audio(
|
| 276 |
label="π€ Reference Audio (Voice to Clone)",
|
| 277 |
-
info
|
| 278 |
type="filepath",
|
| 279 |
sources=["upload", "microphone"]
|
| 280 |
)
|
| 281 |
|
| 282 |
input_audio = gr.Audio(
|
| 283 |
label="π΅ Input Audio (Content to Transform)",
|
| 284 |
-
info
|
| 285 |
type="filepath",
|
| 286 |
sources=["upload", "microphone"]
|
| 287 |
)
|
|
@@ -311,6 +309,27 @@ with gr.Blocks(title="π FIXED Voice Cloning - No Generate() Errors") as demo:
|
|
| 311 |
interactive=False
|
| 312 |
)
|
| 313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
# Event handler
|
| 315 |
clone_btn.click(
|
| 316 |
fn=voice_to_voice_clone_fixed,
|
|
|
|
| 115 |
return False
|
| 116 |
|
| 117 |
def voice_to_voice_clone_fixed(reference_audio, input_audio, language="en"):
|
| 118 |
+
"""FIXED Voice-to-Voice Cloning - No more generate() errors!"""
|
|
|
|
|
|
|
| 119 |
try:
|
| 120 |
if not reference_audio or not input_audio:
|
| 121 |
return None, "β Please upload both reference and input audio files!"
|
|
|
|
| 224 |
startup_msg = f"β οΈ Startup issue: {str(e)}"
|
| 225 |
startup_color = "#f8d7da"
|
| 226 |
|
| 227 |
+
# Create Gradio Interface - FIXED (removed 'info' parameters)
|
| 228 |
with gr.Blocks(title="π FIXED Voice Cloning - No Generate() Errors") as demo:
|
| 229 |
|
| 230 |
gr.HTML("""
|
|
|
|
| 248 |
<h4 style="color: #0c5460;">π§ How This Fix Works:</h4>
|
| 249 |
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
|
| 250 |
<div>
|
| 251 |
+
<h5>β Previous Problems:</h5>
|
| 252 |
<ul>
|
| 253 |
<li><code>'GPT2InferenceModel' object has no attribute 'generate'</code></li>
|
| 254 |
+
<li><code>TypeError: Audio.__init__() got an unexpected keyword argument 'info'</code></li>
|
| 255 |
<li>High-level API internally called non-existent method</li>
|
|
|
|
| 256 |
</ul>
|
| 257 |
</div>
|
| 258 |
<div>
|
|
|
|
| 260 |
<ul>
|
| 261 |
<li><strong>Manual Loading:</strong> Direct XTTS model initialization</li>
|
| 262 |
<li><strong>Direct Inference:</strong> Uses <code>model.inference()</code> not generate()</li>
|
| 263 |
+
<li><strong>Fixed UI:</strong> Removed unsupported <code>info</code> parameters</li>
|
| 264 |
</ul>
|
| 265 |
</div>
|
| 266 |
</div>
|
| 267 |
</div>
|
| 268 |
""")
|
| 269 |
|
| 270 |
+
# Main interface - FIXED: Removed 'info' parameters
|
| 271 |
with gr.Row():
|
| 272 |
with gr.Column():
|
| 273 |
reference_audio = gr.Audio(
|
| 274 |
label="π€ Reference Audio (Voice to Clone)",
|
| 275 |
+
# REMOVED: info parameter to fix runtime error
|
| 276 |
type="filepath",
|
| 277 |
sources=["upload", "microphone"]
|
| 278 |
)
|
| 279 |
|
| 280 |
input_audio = gr.Audio(
|
| 281 |
label="π΅ Input Audio (Content to Transform)",
|
| 282 |
+
# REMOVED: info parameter to fix runtime error
|
| 283 |
type="filepath",
|
| 284 |
sources=["upload", "microphone"]
|
| 285 |
)
|
|
|
|
| 309 |
interactive=False
|
| 310 |
)
|
| 311 |
|
| 312 |
+
# Usage instructions
|
| 313 |
+
gr.HTML("""
|
| 314 |
+
<div style="padding: 20px; background: #f8f9fa; border-radius: 10px; margin-top: 20px;">
|
| 315 |
+
<h4 style="color: #495057;">π Usage Instructions:</h4>
|
| 316 |
+
<ol style="padding-left: 20px; line-height: 1.6;">
|
| 317 |
+
<li><strong>Reference Audio:</strong> Upload 6+ seconds of clear speech (voice to clone)</li>
|
| 318 |
+
<li><strong>Input Audio:</strong> Upload speech content to transform</li>
|
| 319 |
+
<li><strong>Language:</strong> Select the language of the content</li>
|
| 320 |
+
<li><strong>Click "Clone Voice"</strong> and wait for processing (1-2 minutes)</li>
|
| 321 |
+
<li><strong>Download Result:</strong> Same content, different voice!</li>
|
| 322 |
+
</ol>
|
| 323 |
+
|
| 324 |
+
<h5 style="color: #198754; margin-top: 15px;">β
Runtime Errors Fixed:</h5>
|
| 325 |
+
<ul style="padding-left: 20px;">
|
| 326 |
+
<li>Removed unsupported <code>info</code> parameters from Audio components</li>
|
| 327 |
+
<li>Fixed generate() method error with direct inference</li>
|
| 328 |
+
<li>Added PyTorch 2.6 compatibility patches</li>
|
| 329 |
+
</ul>
|
| 330 |
+
</div>
|
| 331 |
+
""")
|
| 332 |
+
|
| 333 |
# Event handler
|
| 334 |
clone_btn.click(
|
| 335 |
fn=voice_to_voice_clone_fixed,
|