Mujeeb26 commited on
Commit
3227b2b
·
verified ·
1 Parent(s): d37f3a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -32
app.py CHANGED
@@ -1,43 +1,31 @@
1
  import gradio as gr
2
- import os
3
- import requests
4
- import torch
5
- import asyncio
6
  import edge_tts
 
 
7
 
8
- # Model files download logic
9
- PTH_URL = "https://huggingface.co/spaces/Mujeeb26/Mujeebvoice/resolve/main/Mujeeb_Voice.pth"
10
- INDEX_URL = "https://huggingface.co/spaces/Mujeeb26/Mujeebvoice/resolve/main/Mujeeb_Voice.index"
11
-
12
- def setup():
13
- if not os.path.exists("model.pth"):
14
- open("model.pth", "wb").write(requests.get(PTH_URL).content)
15
- if not os.path.exists("model.index"):
16
- open("model.index", "wb").write(requests.get(INDEX_URL).content)
17
- return "✅ Mujeeb Voice Model is Active!"
18
 
19
- async def generate_voice(text):
20
- if not text:
21
- return None
22
 
23
- # 1. Base Voice (Urdu/Sindhi accent ke liye)
24
  communicate = edge_tts.Communicate(text, "ur-PK-AsadNeural")
25
- await communicate.save("base_audio.mp3")
26
 
27
- # Yahan asli RVC conversion logic hona chahiye.
28
- # Agar model crash kare, toh humein Applio ka sahara lena hoga.
29
- return "base_audio.mp3"
 
30
 
31
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
32
- gr.Markdown("# 🎙️ Mujeeb AI Sindhi Voice")
33
- status = gr.Markdown(setup())
34
-
35
- with gr.Row():
36
- txt = gr.Textbox(label="Sindhi/English Text Likhen", placeholder="Kiyan ahyo?")
37
- btn = gr.Button("Awaaz Banayein", variant="primary")
38
 
39
- out = gr.Audio(label="AI Voice Output", type="filepath")
40
-
41
- btn.click(fn=generate_voice, inputs=txt, outputs=out)
 
 
 
42
 
43
  demo.launch()
 
1
  import gradio as gr
 
 
 
 
2
  import edge_tts
3
+ import asyncio
4
+ import os
5
 
6
+ # Aapka Model Link
7
+ MODEL_LINK = "https://huggingface.co/spaces/Mujeeb26/Mujeebvoice/resolve/main/Mujeeb_Voice.pth"
 
 
 
 
 
 
 
 
8
 
9
+ async def convert_to_mujeeb(text, pitch):
10
+ if not text: return None
 
11
 
12
+ # 1. Pehle Edge-TTS se saaf Urdu/Sindhi awaaz banegi
13
  communicate = edge_tts.Communicate(text, "ur-PK-AsadNeural")
14
+ await communicate.save("temp_base.mp3")
15
 
16
+ # 2. Yahan RVC Engine aapki .pth file apply karega
17
+ # NOTE: Abhi hum sirf base sun rahe hain, .pth apply karne ke liye
18
+ # humein 'vc_infer' function ko call karna hai.
19
+ return "temp_base.mp3"
20
 
21
+ with gr.Blocks() as demo:
22
+ gr.Markdown("# 🎙️ Mujeeb AI Voice (Final Phase)")
 
 
 
 
 
23
 
24
+ input_text = gr.Textbox(label="Sindhi/Urdu Text", value="توھان ڪيئن آھيو؟")
25
+ pitch_slider = gr.Slider(minimum=-12, maximum=12, value=0, label="Awaaz Bhaari ya Patli Karein (Pitch)")
26
+ btn = gr.Button("Mujeeb ki Awaaz Banayein")
27
+ output_audio = gr.Audio(label="Result")
28
+
29
+ btn.click(convert_to_mujeeb, inputs=[input_text, pitch_slider], outputs=output_audio)
30
 
31
  demo.launch()