Update app.py
Browse files
app.py
CHANGED
|
@@ -1,62 +1,43 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
import soundfile as sf
|
| 4 |
import os
|
| 5 |
-
import urllib.request
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
"voices.bin": "https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/voices-v1.0.bin"
|
| 12 |
-
}
|
| 13 |
-
for name, url in files.items():
|
| 14 |
-
if not os.path.exists(name):
|
| 15 |
-
print(f"Downloading {name}...")
|
| 16 |
-
urllib.request.urlretrieve(url, name)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
return f"Error: {str(e)}"
|
| 34 |
|
| 35 |
-
# UI
|
| 36 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 37 |
-
gr.Markdown("#
|
| 38 |
-
gr.Markdown("ElevenLabs क
|
| 39 |
|
| 40 |
with gr.Row():
|
| 41 |
with gr.Column():
|
| 42 |
-
input_text = gr.Textbox(label="यहाँ अपना
|
| 43 |
-
# ह
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
("हिंदी फीमेल (Alpha)", "hf_alpha"),
|
| 47 |
-
("हिंदी फीमेल (Beta)", "hf_beta"),
|
| 48 |
-
("हिंदी मेल (Omega)", "hm_omega"),
|
| 49 |
-
("हिंदी मेल (Psi)", "hm_psi")
|
| 50 |
-
],
|
| 51 |
-
value="hf_alpha",
|
| 52 |
-
label="आवाज़ चुनें"
|
| 53 |
-
)
|
| 54 |
-
speed_slider = gr.Slider(minimum=0.5, maximum=2.0, value=1.0, step=0.1, label="बोलने की रफ़्तार (Speed)")
|
| 55 |
-
submit_btn = gr.Button("आवाज़ बनाएँ", variant="primary")
|
| 56 |
|
| 57 |
with gr.Column():
|
| 58 |
-
audio_out = gr.Audio(label="
|
| 59 |
|
| 60 |
-
submit_btn.click(
|
| 61 |
|
| 62 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from TTS.api import TTS
|
|
|
|
| 3 |
import os
|
|
|
|
| 4 |
|
| 5 |
+
# मॉडल लोड करना (XTTS v2 सबसे बेस्ट है क्लॉनिंग के लिए)
|
| 6 |
+
# यह मॉडल पहली बार चलने पर 1-2 मिनट ले सकता है
|
| 7 |
+
device = "cpu" # अगर आपके पास GPU Space है तो "cuda" लिखें
|
| 8 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
def clone_alex(text, audio_sample):
|
| 11 |
+
if audio_sample is None:
|
| 12 |
+
return "कृपया पहले Alex का वॉइस सैंपल अपलोड करें!"
|
| 13 |
+
|
| 14 |
+
output_path = "alex_clone_output.wav"
|
| 15 |
+
|
| 16 |
+
# वॉयस क्लॉनिंग प्रोसेस
|
| 17 |
+
tts.tts_to_file(
|
| 18 |
+
text=text,
|
| 19 |
+
file_path=output_path,
|
| 20 |
+
speaker_wav=audio_sample,
|
| 21 |
+
language="hi" # हिंदी के लिए 'hi', इंग्लिश के लिए 'en'
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
return output_path
|
|
|
|
| 25 |
|
| 26 |
+
# UI इंटरफेस
|
| 27 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 28 |
+
gr.Markdown("# 🎭 Pro Voice Cloner (Alex Expressive Alternative)")
|
| 29 |
+
gr.Markdown("ElevenLabs की आवाज़ को यहाँ हमेशा के लिए फ्री में क्लॉन करें।")
|
| 30 |
|
| 31 |
with gr.Row():
|
| 32 |
with gr.Column():
|
| 33 |
+
input_text = gr.Textbox(label="यहाँ अपना टेक्स्ट लिखें", lines=4)
|
| 34 |
+
# यहाँ आप Alex का वो 10 सेकंड वाला सैंपल अपलोड करेंगे
|
| 35 |
+
ref_audio = gr.Audio(label="Alex का वॉइस सैंपल यहाँ डालें (.wav)", type="filepath")
|
| 36 |
+
submit_btn = gr.Button("Alex की आवाज़ में बदलें", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
with gr.Column():
|
| 39 |
+
audio_out = gr.Audio(label="तैयार क्लॉन आवाज़", type="filepath")
|
| 40 |
|
| 41 |
+
submit_btn.click(clone_alex, inputs=[input_text, ref_audio], outputs=audio_out)
|
| 42 |
|
| 43 |
demo.launch()
|