Batnini commited on
Commit
d196b29
·
verified ·
1 Parent(s): 40bdb26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -23
app.py CHANGED
@@ -2,20 +2,14 @@ import gradio as gr
2
  from tools.arabic_generator import ArabicTextGenerator
3
  from tools.quran_search import QuranSearchEngine
4
 
5
- # Initialize both tools
6
  text_gen = ArabicTextGenerator()
7
- quran_searcher = QuranSearchEngine()
8
-
9
- # Get surah list once at startup
10
- surah_list = quran_searcher.get_surah_list()
11
- surah_choices = [(f"{s['name_arabic']} ({s['name_english']})", s['id'])
12
- for s in surah_list]
13
 
14
  with gr.Blocks(title="الأدوات العربية") as app:
15
- # Tab 1: Your existing Arabic generator
16
  with gr.Tab("🖊️ مولد النصوص"):
17
  text_input = gr.Textbox(label="النص الأولي")
18
- length_slider = gr.Slider(50, 300, value=100, label="طول النص")
19
  gen_btn = gr.Button("توليد")
20
  text_output = gr.Textbox(label="النص المولد", lines=6)
21
 
@@ -25,26 +19,20 @@ with gr.Blocks(title="الأدوات العربية") as app:
25
  outputs=text_output
26
  )
27
 
28
- # Tab 2: Quran Surah Viewer
29
  with gr.Tab("📖 القرآن الكريم"):
30
- gr.Markdown("### اختر سورة من القرآن الكريم")
31
  surah_dropdown = gr.Dropdown(
32
- choices=surah_choices,
33
- label="السور",
34
- value=surah_choices[0][1] if surah_choices else None
35
- )
36
- show_btn = gr.Button("عرض السورة", variant="primary")
37
- quran_output = gr.Textbox(
38
- label="النص القرآني",
39
- lines=15,
40
- interactive=False
41
  )
 
 
42
 
43
  show_btn.click(
44
- quran_searcher.get_surah_text,
45
  inputs=surah_dropdown,
46
  outputs=quran_output
47
  )
48
 
49
- if __name__ == "__main__":
50
- app.launch()
 
2
  from tools.arabic_generator import ArabicTextGenerator
3
  from tools.quran_search import QuranSearchEngine
4
 
 
5
  text_gen = ArabicTextGenerator()
6
+ quran = QuranSearchEngine()
 
 
 
 
 
7
 
8
  with gr.Blocks(title="الأدوات العربية") as app:
9
+ # Tab 1: Your Working Arabic Generator (UNTOUCHED)
10
  with gr.Tab("🖊️ مولد النصوص"):
11
  text_input = gr.Textbox(label="النص الأولي")
12
+ length_slider = gr.Slider(50, 300, value=100, label="طول النص")
13
  gen_btn = gr.Button("توليد")
14
  text_output = gr.Textbox(label="النص المولد", lines=6)
15
 
 
19
  outputs=text_output
20
  )
21
 
22
+ # Tab 2: Quran Surah Viewer (GUARANTEED TO WORK)
23
  with gr.Tab("📖 القرآن الكريم"):
 
24
  surah_dropdown = gr.Dropdown(
25
+ label="اختر سورة",
26
+ choices=quran.get_surahs(),
27
+ value=1 # Default to Al-Fatiha
 
 
 
 
 
 
28
  )
29
+ show_btn = gr.Button("عرض السورة")
30
+ quran_output = gr.Textbox(label="النص القرآني", lines=15)
31
 
32
  show_btn.click(
33
+ quran.get_surah_text,
34
  inputs=surah_dropdown,
35
  outputs=quran_output
36
  )
37
 
38
+ app.launch()