Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,13 @@ from tools.quran_search import QuranSearchEngine
|
|
| 6 |
text_gen = ArabicTextGenerator()
|
| 7 |
quran_searcher = QuranSearchEngine()
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
with gr.Blocks(title="الأدوات العربية") as app:
|
| 10 |
-
# Tab 1:
|
| 11 |
with gr.Tab("🖊️ مولد النصوص"):
|
| 12 |
text_input = gr.Textbox(label="النص الأولي")
|
| 13 |
length_slider = gr.Slider(50, 300, value=100, label="طول النص")
|
|
@@ -22,15 +27,21 @@ with gr.Blocks(title="الأدوات العربية") as app:
|
|
| 22 |
|
| 23 |
# Tab 2: Quran Surah Viewer
|
| 24 |
with gr.Tab("📖 القرآن الكريم"):
|
|
|
|
| 25 |
surah_dropdown = gr.Dropdown(
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
)
|
| 29 |
-
show_btn = gr.Button("عرض السورة")
|
| 30 |
-
quran_output = gr.Textbox(label="النص القرآني", lines=15)
|
| 31 |
|
| 32 |
show_btn.click(
|
| 33 |
-
quran_searcher.
|
| 34 |
inputs=surah_dropdown,
|
| 35 |
outputs=quran_output
|
| 36 |
)
|
|
|
|
| 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="طول النص")
|
|
|
|
| 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 |
)
|