Raybilhelp commited on
Commit
1085965
·
verified ·
1 Parent(s): f517129

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -2,7 +2,6 @@ import os
2
  import gradio as gr
3
  import requests
4
 
5
- # গ্রাডিওর জন্য ইন্টারনাল রাউটিং কাজ করে
6
  API_URL = "https://api-inference.huggingface.co/models/facebook/mms-tts-eng"
7
  HF_TOKEN = os.getenv("HF_TOKEN", "")
8
  headers = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {}
@@ -11,7 +10,7 @@ def text_to_speech(text):
11
  if not text.strip():
12
  return None, "অনুগ্রহ করে কিছু টেক্সট লিখুন।"
13
  try:
14
- response = requests.post(API_URL, headers=headers, json={"inputs": text}, timeout=30)
15
  if response.status_code == 200:
16
  output_path = "voice.wav"
17
  with open(output_path, "wb") as f:
@@ -22,9 +21,11 @@ def text_to_speech(text):
22
  except Exception as e:
23
  return None, f"নেটওয়ার্ক সমস্যা: {str(e)}"
24
 
25
- # সুন্দর ডা্ক িম য়ে UI
26
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
27
- gr.Markdown("# 🎙️ Raybil Voice AI Engine (Gradio Embedded)")
 
 
28
  with gr.Row():
29
  with gr.Column():
30
  input_text = gr.Textbox(label="আপনার টেক্সট লিখুন", placeholder="এখানে ইংরেজি টেক্সট লিখুন...", lines=4)
@@ -35,4 +36,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
35
 
36
  submit_btn.click(fn=text_to_speech, inputs=input_text, outputs=[output_audio, status_text])
37
 
38
- demo.launch()
 
 
 
2
  import gradio as gr
3
  import requests
4
 
 
5
  API_URL = "https://api-inference.huggingface.co/models/facebook/mms-tts-eng"
6
  HF_TOKEN = os.getenv("HF_TOKEN", "")
7
  headers = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {}
 
10
  if not text.strip():
11
  return None, "অনুগ্রহ করে কিছু টেক্সট লিখুন।"
12
  try:
13
+ response = requests.post(API_URL, headers=headers, json={"inputs": text}, timeout=60)
14
  if response.status_code == 200:
15
  output_path = "voice.wav"
16
  with open(output_path, "wb") as f:
 
21
  except Exception as e:
22
  return None, f"নেটওয়ার্ক সমস্যা: {str(e)}"
23
 
24
+ # Gradio 6.0+ এিঅনুযাী theme এখন launch() এ দিতহয়
25
+ demo = gr.Blocks()
26
+
27
+ with demo:
28
+ gr.Markdown("# 🎙️ Raybil Voice AI Engine")
29
  with gr.Row():
30
  with gr.Column():
31
  input_text = gr.Textbox(label="আপনার টেক্সট লিখুন", placeholder="এখানে ইংরেজি টেক্সট লিখুন...", lines=4)
 
36
 
37
  submit_btn.click(fn=text_to_speech, inputs=input_text, outputs=[output_audio, status_text])
38
 
39
+ # হাগিংফেস স্পেসের জন্য পোর্ট ৭৮৬০ এবং SSR ডিজেবল রাখা ভালো
40
+ if __name__ == "__main__":
41
+ demo.launch(server_name="0.0.0.0", server_port=7860)