Offex commited on
Commit
8faa3fe
·
verified ·
1 Parent(s): daade39

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from kokoro_onnx import Kokoro
3
+ import soundfile as sf
4
+ import numpy as np
5
+
6
+ # मॉडल लोड करना (यह पहली बार में थोड़ा समय ले सकता है)
7
+ kokoro = Kokoro("model.onnx", "voices.json")
8
+
9
+ def generate_voice(text, voice_style):
10
+ # आवाज़ जनरेट करने का फंक्शन
11
+ samples, sample_rate = kokoro.create(text, voice=voice_style, speed=1.0, lang="en-us")
12
+ sf.write("output.wav", samples, sample_rate)
13
+ return "output.wav"
14
+
15
+ # इंटरफेस डिज़ाइन
16
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
17
+ gr.Markdown("# 🎙️ My Private Hyper-Realistic TTS")
18
+ gr.Markdown("ElevenLabs जैसा अनुभव, अब बिना किसी लिमिट के।")
19
+
20
+ with gr.Row():
21
+ input_text = gr.Textbox(label="यहाँ अपना टेक्स्ट लिखें", lines=3)
22
+ # यहाँ आप अलग-अलग स्टाइल चुन सकते हैं (Bella, Adam, etc. के विकल्प यहाँ मिल जाएंगे)
23
+ voice_opt = gr.Dropdown(
24
+ choices=["af_bella", "af_sarah", "am_adam", "am_michael"],
25
+ value="af_bella",
26
+ label="आवाज़ का स्टाइल चुनें"
27
+ )
28
+
29
+ submit_btn = gr.Button("Generate Audio", variant="primary")
30
+ audio_out = gr.Audio(label="तैयार आवाज़", type="filepath")
31
+
32
+ submit_btn.click(generate_voice, inputs=[input_text, voice_opt], outputs=audio_out)
33
+
34
+ demo.launch()