Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,35 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
return "कृपया पहले Alex का वॉयस सैंपल अपलोड करें!"
|
| 9 |
-
|
| 10 |
-
# यहाँ क्लॉनिंग की लॉजिक काम करेगी
|
| 11 |
-
# चूँकि CPU पर पूरा मॉडल लोड करना मुश्किल है, हम 'Pre-trained' weights का उपयोग करेंगे
|
| 12 |
-
try:
|
| 13 |
-
output_path = "cloned_alex.wav"
|
| 14 |
-
# क्लॉनिंग प्रोसेस (Reference Audio से Alex की टोन निकालना)
|
| 15 |
-
# नोट: यह कोड 'Zero-GPU' पर सुपर-फास्ट चलेगा
|
| 16 |
-
return reference_audio # डेमो के लिए अभी यह इनपुट रिटर्न करेगा, एक्चुअल सेटअप में जनरेटेड फाइल देगा
|
| 17 |
-
except Exception as e:
|
| 18 |
-
return str(e)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
gr.Markdown("ElevenLabs की Alex आवाज़ यहाँ क्लॉन करें।")
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
with gr.Row():
|
| 26 |
with gr.Column():
|
| 27 |
-
input_text = gr.Textbox(label="
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
with gr.Column():
|
| 33 |
-
audio_out = gr.Audio(label="Alex की क्लॉन आवाज़")
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from TTS.api import TTS
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# मॉडल लोड करना (इसे थोड़ा समय लगेगा, धैर्य रखें)
|
| 6 |
+
print("Loading Alex Cloner...")
|
| 7 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def alex_clone(text, audio_file):
|
| 10 |
+
if audio_file is None:
|
| 11 |
+
return "Deepak भाई, पहले Alex का सैंपल तो डालो!"
|
|
|
|
| 12 |
|
| 13 |
+
output_path = "output.wav"
|
| 14 |
+
# क्लॉनिंग और जनरेशन
|
| 15 |
+
tts.tts_to_file(
|
| 16 |
+
text=text,
|
| 17 |
+
speaker_wav=audio_file,
|
| 18 |
+
language="hi", # हिंदी के लिए
|
| 19 |
+
file_path=output_path
|
| 20 |
+
)
|
| 21 |
+
return output_path
|
| 22 |
+
|
| 23 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 24 |
+
gr.Markdown("# 🎭 Alex Expressive Voice Clone (PRO)")
|
| 25 |
with gr.Row():
|
| 26 |
with gr.Column():
|
| 27 |
+
input_text = gr.Textbox(label="Text (Hindi/English)", lines=4)
|
| 28 |
+
ref_audio = gr.Audio(label="Upload Alex Sample (10-15s)", type="filepath")
|
| 29 |
+
btn = gr.Button("Magic Generate ✨", variant="primary")
|
| 30 |
+
audio_out = gr.Audio(label="Alex's Voice")
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
btn.click(alex_clone, inputs=[input_text, ref_audio], outputs=audio_out)
|
| 33 |
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|