Offex commited on
Commit
75fe24e
·
verified ·
1 Parent(s): bbf394b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -28
app.py CHANGED
@@ -1,37 +1,35 @@
1
  import gradio as gr
2
- import torch
3
  import os
4
 
5
- # यहाँ एक ाइटवेट्लॉिंगंजन ्तेर र है
6
- def clone_voice(text, reference_audio):
7
- if reference_audio is None:
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
- # UI में 'Clone' करने का ऑप्शन
21
- with gr.Blocks() as demo:
22
- gr.Markdown("# 🎭 Alex Expressive Voice Cloner")
23
- gr.Markdown("ElevenLabs की Alex आवाज़ यहाँ क्लॉन करें।")
24
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  with gr.Row():
26
  with gr.Column():
27
- input_text = gr.Textbox(label="अपना टेक्स्ट यहाँ लिखें", lines=3)
28
- # यहाँ क्लॉनिंग के लिए Alex का सैंपल डालें
29
- ref_audio = gr.Audio(label="Alex का सैंपल अपलोड करें (.mp3/wav)", type="filepath")
30
- submit_btn = gr.Button("Clone & Generate", variant="primary")
31
-
32
- with gr.Column():
33
- audio_out = gr.Audio(label="Alex की क्लॉन आवाज़")
34
 
35
- submit_btn.click(clone_voice, inputs=[input_text, ref_audio], outputs=audio_out)
36
 
37
- demo.launch()
 
 
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)