Update app.py
Browse files
app.py
CHANGED
|
@@ -13,17 +13,319 @@ api = HfApi()
|
|
| 13 |
|
| 14 |
SURAH_NAMES = ["الفاتحة", "البقرة", "آل عمران", "النساء", "المائدة", "الأنعام", "الأعراف", "الأنفال", "التوبة", "يونس", "هود", "يوسف", "الرعد", "إبراهيم", "الحجر", "النحل", "الإسراء", "الكهف", "مريم", "طه", "الأنبياء", "الحج", "المؤمنون", "النور", "الفرقان", "الشعراء", "النمل", "القصص", "العنكبوت", "الروم", "لقمان", "السجدة", "الأحزاب", "سبأ", "فاطر", "يس", "الصافات", "ص", "الزمر", "غافر", "فصلت", "الشورى", "الزخرف", "الدخان", "الجاثية", "الأحقاف", "محمد", "الفتح", "الحجرات", "ق", "الذاريات", "الطور", "النجم", "القمر", "الرحمن", "الواقعة", "الحديد", "المجادلة", "الحشر", "الممتحنة", "الصف", "الجمعة", "المنافقون", "التغابن", "الطلاق", "التحريم", "الملك", "القلم", "الحاقة", "المعارج", "نوح", "الجن", "المزمل", "المدثر", "القيامة", "الإنسان", "المرسلات", "النبأ", "النازعات", "عبس", "التكوير", "الانفطار", "المطففين", "الانشقاق", "البروج", "الطارق", "الأعلى", "الغاشية", "الفجر", "البلد", "الشمس", "الليل", "الضحى", "الشرح", "التين", "العلق", "القدر", "البينة", "الزلزلة", "العاديات", "القارعة", "التكاثر", "العصر", "الهمزة", "الفيل", "قريش", "الماعون", "الكوثر", "الكافرون", "النصر", "المسد", "الإخلاص", "الفلق", "الناس"]
|
| 15 |
|
|
|
|
| 16 |
custom_css = """
|
| 17 |
-
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Reem+Kufi:wght@700&display=swap');
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
"""
|
| 28 |
|
| 29 |
def clean_text(text):
|
|
@@ -45,7 +347,15 @@ def load_quran_data():
|
|
| 45 |
ALL_AYAT = load_quran_data()
|
| 46 |
|
| 47 |
def get_stats_html(user_session_count):
|
| 48 |
-
return f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
def on_submit(audio, current_idx, session_count):
|
| 51 |
if not audio:
|
|
@@ -61,9 +371,20 @@ def on_submit(audio, current_idx, session_count):
|
|
| 61 |
new_sess = session_count + 1
|
| 62 |
next_idx = (current_idx + 1) % len(ALL_AYAT)
|
| 63 |
nv = ALL_AYAT[next_idx]
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
except Exception as e:
|
| 66 |
-
return f"<div class='alert-box alert-error'>❌ خطأ: {str(e)}</div>", gr.update(), gr.update(), current_idx, session_count, gr.update()
|
| 67 |
|
| 68 |
def jump_logic(s_name, a_num):
|
| 69 |
try:
|
|
@@ -72,48 +393,151 @@ def jump_logic(s_name, a_num):
|
|
| 72 |
target = ALL_AYAT[t_idx]
|
| 73 |
return "", f"<div class='ayah-text'>{target['text']}</div>", f"### سورة {target['surah_name']} - آية {target['ayah']}", t_idx
|
| 74 |
except:
|
| 75 |
-
return "<div class='alert-box alert-error'>⚠️ لم يتم العثور على الآية</div>", gr.update(), gr.update(), 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
# --- بناء الواجهة ---
|
| 78 |
-
with gr.Blocks(title="منصة تلاوة
|
| 79 |
idx_state = gr.State(random.randint(0, len(ALL_AYAT)-1))
|
| 80 |
sess_state = gr.State(0)
|
| 81 |
|
|
|
|
| 82 |
gr.HTML("""
|
| 83 |
-
<div id="
|
| 84 |
-
<
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
</div>
|
| 87 |
""")
|
| 88 |
|
| 89 |
-
with gr.Column(
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
|
|
|
| 92 |
with gr.Row():
|
| 93 |
-
with gr.Column(scale=
|
| 94 |
with gr.Group():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
curr_v = ALL_AYAT[idx_state.value]
|
| 96 |
info_text = gr.Markdown(f"### سورة {curr_v['surah_name']} - آية {curr_v['ayah']}")
|
| 97 |
text_html = gr.HTML(f"<div class='ayah-text'>{curr_v['text']}</div>")
|
| 98 |
|
| 99 |
with gr.Row():
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
status_msg = gr.HTML("")
|
| 103 |
|
| 104 |
-
with gr.Column(scale=
|
| 105 |
with gr.Group():
|
| 106 |
-
gr.
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
with gr.Accordion("🔍 بحث
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
# تشغيل
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
SURAH_NAMES = ["الفاتحة", "البقرة", "آل عمران", "النساء", "المائدة", "الأنعام", "الأعراف", "الأنفال", "التوبة", "يونس", "هود", "يوسف", "الرعد", "إبراهيم", "الحجر", "النحل", "الإسراء", "الكهف", "مريم", "طه", "الأنبياء", "الحج", "المؤمنون", "النور", "الفرقان", "الشعراء", "النمل", "القصص", "العنكبوت", "الروم", "لقمان", "السجدة", "الأحزاب", "سبأ", "فاطر", "يس", "الصافات", "ص", "الزمر", "غافر", "فصلت", "الشورى", "الزخرف", "الدخان", "الجاثية", "الأحقاف", "محمد", "الفتح", "الحجرات", "ق", "الذاريات", "الطور", "النجم", "القمر", "الرحمن", "الواقعة", "الحديد", "المجادلة", "الحشر", "الممتحنة", "الصف", "الجمعة", "المنافقون", "التغابن", "الطلاق", "التحريم", "الملك", "القلم", "الحاقة", "المعارج", "نوح", "الجن", "المزمل", "المدثر", "القيامة", "الإنسان", "المرسلات", "النبأ", "النازعات", "عبس", "التكوير", "الانفطار", "المطففين", "الانشقاق", "البروج", "الطارق", "الأعلى", "الغاشية", "الفجر", "البلد", "الشمس", "الليل", "الضحى", "الشرح", "التين", "العلق", "القدر", "البينة", "الزلزلة", "العاديات", "القارعة", "التكاثر", "العصر", "الهمزة", "الفيل", "قريش", "الماعون", "الكوثر", "الكافرون", "النصر", "المسد", "الإخلاص", "الفلق", "الناس"]
|
| 15 |
|
| 16 |
+
# تحسين CSS لتكون أكثر جمالية
|
| 17 |
custom_css = """
|
| 18 |
+
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Reem+Kufi:wght@400;500;600;700&family=Scheherazade+New:wght@400;700&display=swap');
|
| 19 |
+
|
| 20 |
+
:root {
|
| 21 |
+
--primary-color: #1a5f7a;
|
| 22 |
+
--secondary-color: #57c5b6;
|
| 23 |
+
--accent-color: #159895;
|
| 24 |
+
--gold-color: #d4af37;
|
| 25 |
+
--light-bg: #f8f9fa;
|
| 26 |
+
--dark-bg: #1a252f;
|
| 27 |
+
--success-color: #28a745;
|
| 28 |
+
--warning-color: #ffc107;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
* {
|
| 32 |
+
font-family: 'Reem Kufi', sans-serif;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
body {
|
| 36 |
+
direction: rtl;
|
| 37 |
+
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
| 38 |
+
min-height: 100vh;
|
| 39 |
+
margin: 0;
|
| 40 |
+
padding: 0;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
.gradio-container {
|
| 44 |
+
max-width: 1400px !important;
|
| 45 |
+
margin: 0 auto !important;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/* الهيدر */
|
| 49 |
+
#header-section {
|
| 50 |
+
background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
|
| 51 |
+
min-height: 50vh;
|
| 52 |
+
display: flex;
|
| 53 |
+
flex-direction: column;
|
| 54 |
+
justify-content: center;
|
| 55 |
+
align-items: center;
|
| 56 |
+
text-align: center;
|
| 57 |
+
padding: 60px 20px;
|
| 58 |
+
border-radius: 0 0 60px 60px;
|
| 59 |
+
position: relative;
|
| 60 |
+
overflow: hidden;
|
| 61 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
#header-section::before {
|
| 65 |
+
content: '';
|
| 66 |
+
position: absolute;
|
| 67 |
+
top: 0;
|
| 68 |
+
left: 0;
|
| 69 |
+
right: 0;
|
| 70 |
+
bottom: 0;
|
| 71 |
+
background: url('https://images.unsplash.com/photo-1541250628459-d8f2f0157289?q=80&w=2070&auto=format&fit=crop') center/cover;
|
| 72 |
+
opacity: 0.15;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.main-title {
|
| 76 |
+
font-family: 'Reem Kufi', sans-serif;
|
| 77 |
+
font-size: 4rem;
|
| 78 |
+
color: white;
|
| 79 |
+
margin-bottom: 10px;
|
| 80 |
+
text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
|
| 81 |
+
position: relative;
|
| 82 |
+
z-index: 1;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.subtitle {
|
| 86 |
+
font-family: 'Scheherazade New', serif;
|
| 87 |
+
font-size: 1.8rem;
|
| 88 |
+
color: var(--gold-color);
|
| 89 |
+
margin-bottom: 30px;
|
| 90 |
+
position: relative;
|
| 91 |
+
z-index: 1;
|
| 92 |
+
font-weight: 700;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.logo-container {
|
| 96 |
+
background: white;
|
| 97 |
+
width: 120px;
|
| 98 |
+
height: 120px;
|
| 99 |
+
border-radius: 50%;
|
| 100 |
+
display: flex;
|
| 101 |
+
align-items: center;
|
| 102 |
+
justify-content: center;
|
| 103 |
+
margin-bottom: 30px;
|
| 104 |
+
box-shadow: 0 8px 25px rgba(0,0,0,0.2);
|
| 105 |
+
position: relative;
|
| 106 |
+
z-index: 1;
|
| 107 |
+
border: 5px solid var(--gold-color);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.logo-text {
|
| 111 |
+
font-family: 'Reem Kufi', sans-serif;
|
| 112 |
+
font-size: 2.5rem;
|
| 113 |
+
color: var(--primary-color);
|
| 114 |
+
font-weight: 700;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/* البطاقات */
|
| 118 |
+
.card-box {
|
| 119 |
+
background: white;
|
| 120 |
+
border-radius: 20px;
|
| 121 |
+
padding: 30px;
|
| 122 |
+
box-shadow: 0 15px 35px rgba(0,0,0,0.08);
|
| 123 |
+
margin-bottom: 25px;
|
| 124 |
+
border-top: 8px solid var(--secondary-color);
|
| 125 |
+
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 126 |
+
position: relative;
|
| 127 |
+
overflow: hidden;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.card-box:hover {
|
| 131 |
+
transform: translateY(-5px);
|
| 132 |
+
box-shadow: 0 20px 40px rgba(0,0,0,0.12);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.card-box::before {
|
| 136 |
+
content: '';
|
| 137 |
+
position: absolute;
|
| 138 |
+
top: 0;
|
| 139 |
+
left: 0;
|
| 140 |
+
right: 0;
|
| 141 |
+
height: 5px;
|
| 142 |
+
background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
/* نص الآية */
|
| 146 |
+
.ayah-container {
|
| 147 |
+
background: linear-gradient(135deg, #fff8e1 0%, #fef9e7 100%);
|
| 148 |
+
border-radius: 15px;
|
| 149 |
+
padding: 40px;
|
| 150 |
+
margin: 20px 0;
|
| 151 |
+
border-right: 8px solid var(--gold-color);
|
| 152 |
+
position: relative;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.ayah-container::before {
|
| 156 |
+
content: "﷽";
|
| 157 |
+
position: absolute;
|
| 158 |
+
top: 10px;
|
| 159 |
+
left: 20px;
|
| 160 |
+
font-size: 2rem;
|
| 161 |
+
color: rgba(0,0,0,0.1);
|
| 162 |
+
font-family: 'Amiri', serif;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.ayah-text {
|
| 166 |
+
font-family: 'Amiri', serif;
|
| 167 |
+
font-size: 2.8rem;
|
| 168 |
+
line-height: 1.9;
|
| 169 |
+
color: #2c3e50;
|
| 170 |
+
text-align: center;
|
| 171 |
+
font-weight: 700;
|
| 172 |
+
text-shadow: 1px 1px 2px rgba(0,0,0,0.05);
|
| 173 |
+
padding: 20px;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.ayah-info {
|
| 177 |
+
font-family: 'Reem Kufi', sans-serif;
|
| 178 |
+
font-size: 1.5rem;
|
| 179 |
+
color: var(--primary-color);
|
| 180 |
+
text-align: center;
|
| 181 |
+
margin-top: 20px;
|
| 182 |
+
padding: 15px;
|
| 183 |
+
background: rgba(87, 197, 182, 0.1);
|
| 184 |
+
border-radius: 10px;
|
| 185 |
+
border-right: 4px solid var(--secondary-color);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/* الأزرار */
|
| 189 |
+
button {
|
| 190 |
+
font-family: 'Reem Kufi', sans-serif !important;
|
| 191 |
+
font-size: 1.1rem !important;
|
| 192 |
+
border-radius: 12px !important;
|
| 193 |
+
padding: 15px 30px !important;
|
| 194 |
+
transition: all 0.3s ease !important;
|
| 195 |
+
border: none !important;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
button.primary {
|
| 199 |
+
background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%) !important;
|
| 200 |
+
color: white !important;
|
| 201 |
+
box-shadow: 0 5px 15px rgba(26, 95, 122, 0.3) !important;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
button.primary:hover {
|
| 205 |
+
transform: translateY(-3px);
|
| 206 |
+
box-shadow: 0 8px 20px rgba(26, 95, 122, 0.4) !important;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
button.secondary {
|
| 210 |
+
background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%) !important;
|
| 211 |
+
color: white !important;
|
| 212 |
+
box-shadow: 0 5px 15px rgba(255, 193, 7, 0.3) !important;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/* قسم التسجيل */
|
| 216 |
+
.recording-section {
|
| 217 |
+
background: linear-gradient(135deg, var(--dark-bg) 0%, #2c3e50 100%);
|
| 218 |
+
border-radius: 20px;
|
| 219 |
+
padding: 30px;
|
| 220 |
+
color: white;
|
| 221 |
+
margin-top: 30px;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
.recording-title {
|
| 225 |
+
color: var(--gold-color);
|
| 226 |
+
font-size: 1.8rem;
|
| 227 |
+
margin-bottom: 20px;
|
| 228 |
+
text-align: center;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/* الإحصائيات */
|
| 232 |
+
.stats-card {
|
| 233 |
+
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
|
| 234 |
+
border-radius: 15px;
|
| 235 |
+
padding: 25px;
|
| 236 |
+
text-align: center;
|
| 237 |
+
border: 2px solid var(--secondary-color);
|
| 238 |
+
margin: 20px 0;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
.stats-number {
|
| 242 |
+
font-size: 3rem;
|
| 243 |
+
color: var(--primary-color);
|
| 244 |
+
font-weight: 700;
|
| 245 |
+
margin: 10px 0;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
.stats-label {
|
| 249 |
+
font-size: 1.2rem;
|
| 250 |
+
color: #666;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/* التنبيهات */
|
| 254 |
+
.alert-box {
|
| 255 |
+
padding: 20px;
|
| 256 |
+
border-radius: 12px;
|
| 257 |
+
margin: 20px 0;
|
| 258 |
+
text-align: center;
|
| 259 |
+
font-weight: bold;
|
| 260 |
+
font-size: 1.1rem;
|
| 261 |
+
animation: slideIn 0.5s ease;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
@keyframes slideIn {
|
| 265 |
+
from { transform: translateY(-20px); opacity: 0; }
|
| 266 |
+
to { transform: translateY(0); opacity: 1; }
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
.alert-success {
|
| 270 |
+
background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
|
| 271 |
+
color: #155724;
|
| 272 |
+
border-right: 5px solid var(--success-color);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
.alert-error {
|
| 276 |
+
background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
|
| 277 |
+
color: #721c24;
|
| 278 |
+
border-right: 5px solid #dc3545;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/* البحث السريع */
|
| 282 |
+
.search-section {
|
| 283 |
+
background: white;
|
| 284 |
+
border-radius: 15px;
|
| 285 |
+
padding: 25px;
|
| 286 |
+
box-shadow: 0 10px 25px rgba(0,0,0,0.05);
|
| 287 |
+
margin-top: 20px;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
/* تخصيص العناصر */
|
| 291 |
+
.gr-box {
|
| 292 |
+
border-radius: 15px !important;
|
| 293 |
+
border: 2px solid #e9ecef !important;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
.gr-input {
|
| 297 |
+
border-radius: 10px !important;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
/* تذييل الصفحة */
|
| 301 |
+
footer {
|
| 302 |
+
text-align: center;
|
| 303 |
+
padding: 30px;
|
| 304 |
+
margin-top: 50px;
|
| 305 |
+
background: var(--dark-bg);
|
| 306 |
+
color: white;
|
| 307 |
+
border-radius: 30px 30px 0 0;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.footer-text {
|
| 311 |
+
color: var(--gold-color);
|
| 312 |
+
font-size: 1.1rem;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
/* تأثيرات إضافية */
|
| 316 |
+
.pulse {
|
| 317 |
+
animation: pulse 2s infinite;
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
@keyframes pulse {
|
| 321 |
+
0% { transform: scale(1); }
|
| 322 |
+
50% { transform: scale(1.05); }
|
| 323 |
+
100% { transform: scale(1); }
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
.glow {
|
| 327 |
+
text-shadow: 0 0 10px rgba(212, 175, 55, 0.7);
|
| 328 |
+
}
|
| 329 |
"""
|
| 330 |
|
| 331 |
def clean_text(text):
|
|
|
|
| 347 |
ALL_AYAT = load_quran_data()
|
| 348 |
|
| 349 |
def get_stats_html(user_session_count):
|
| 350 |
+
return f"""
|
| 351 |
+
<div class="stats-card">
|
| 352 |
+
<div class="stats-number">{user_session_count}</div>
|
| 353 |
+
<div class="stats-label">عدد تلاواتك في هذه الجلسة</div>
|
| 354 |
+
<div style="margin-top: 15px; font-size: 0.9rem; color: #888;">
|
| 355 |
+
كل تلاوة تساهم في بناء أكبر قاعدة بيانات صوتية للقرآن الكريم
|
| 356 |
+
</div>
|
| 357 |
+
</div>
|
| 358 |
+
"""
|
| 359 |
|
| 360 |
def on_submit(audio, current_idx, session_count):
|
| 361 |
if not audio:
|
|
|
|
| 371 |
new_sess = session_count + 1
|
| 372 |
next_idx = (current_idx + 1) % len(ALL_AYAT)
|
| 373 |
nv = ALL_AYAT[next_idx]
|
| 374 |
+
|
| 375 |
+
success_msg = f"""
|
| 376 |
+
<div class='alert-box alert-success'>
|
| 377 |
+
<div style="font-size: 1.3rem; margin-bottom: 10px;">✅ تم الحفظ بنجاح</div>
|
| 378 |
+
<div>تم رفع تلاوتك للآية {v['ayah']} من سورة {v['surah_name']}</div>
|
| 379 |
+
<div style="margin-top: 10px; font-size: 0.9rem;">
|
| 380 |
+
المعرف الفريد: {unique_id}
|
| 381 |
+
</div>
|
| 382 |
+
</div>
|
| 383 |
+
"""
|
| 384 |
+
|
| 385 |
+
return success_msg, f"<div class='ayah-text'>{nv['text']}</div>", f"### سورة {nv['surah_name']} - آية {nv['ayah']}", next_idx, new_sess, get_stats_html(new_sess)
|
| 386 |
except Exception as e:
|
| 387 |
+
return f"<div class='alert-box alert-error'>❌ خطأ في الرفع: {str(e)}</div>", gr.update(), gr.update(), current_idx, session_count, gr.update()
|
| 388 |
|
| 389 |
def jump_logic(s_name, a_num):
|
| 390 |
try:
|
|
|
|
| 393 |
target = ALL_AYAT[t_idx]
|
| 394 |
return "", f"<div class='ayah-text'>{target['text']}</div>", f"### سورة {target['surah_name']} - آية {target['ayah']}", t_idx
|
| 395 |
except:
|
| 396 |
+
return "<div class='alert-box alert-error'>⚠️ لم يتم العثور على الآية المحددة</div>", gr.update(), gr.update(), 0
|
| 397 |
+
|
| 398 |
+
def random_ayah():
|
| 399 |
+
ni = random.randint(0, len(ALL_AYAT)-1)
|
| 400 |
+
v = ALL_AYAT[ni]
|
| 401 |
+
return f"<div class='ayah-text'>{v['text']}</div>", f"### سورة {v['surah_name']} - آية {v['ayah']}", ni, ""
|
| 402 |
|
| 403 |
+
# --- بناء الواجهة المحسنة ---
|
| 404 |
+
with gr.Blocks(title="مِنَصَّة التِّلَاوَة - Quran Recitation Platform", css=custom_css) as demo:
|
| 405 |
idx_state = gr.State(random.randint(0, len(ALL_AYAT)-1))
|
| 406 |
sess_state = gr.State(0)
|
| 407 |
|
| 408 |
+
# الهيدر الرئيسي
|
| 409 |
gr.HTML("""
|
| 410 |
+
<div id="header-section">
|
| 411 |
+
<div class="logo-container">
|
| 412 |
+
<div class="logo-text">ق</div>
|
| 413 |
+
</div>
|
| 414 |
+
<h1 class="main-title glow">مِنَصَّة التِّلَاوَة</h1>
|
| 415 |
+
<p class="subtitle">مشروع جماعي لجمع وتوثيق تلاوات القرآن الكريم</p>
|
| 416 |
+
<p style="color: rgba(255,255,255,0.9); font-size: 1.1rem; max-width: 800px; position: relative; z-index: 1;">
|
| 417 |
+
ساهم معنا في بناء أكبر قاعدة بيانات صوتية للقرآن الكريم من خلال تسجيل تلاوتك للآيات الكريمة
|
| 418 |
+
</p>
|
| 419 |
</div>
|
| 420 |
""")
|
| 421 |
|
| 422 |
+
with gr.Column():
|
| 423 |
+
# قسم الإحصائيات
|
| 424 |
+
with gr.Row():
|
| 425 |
+
with gr.Column(scale=1):
|
| 426 |
+
gr.HTML(get_stats_html(0))
|
| 427 |
+
with gr.Column(scale=2):
|
| 428 |
+
gr.HTML("""
|
| 429 |
+
<div class="card-box">
|
| 430 |
+
<h3 style="color: var(--primary-color); margin-bottom: 15px;">🎯 الهدف م�� المنصة</h3>
|
| 431 |
+
<p style="line-height: 1.6;">
|
| 432 |
+
هذه المنصة تهدف إلى جمع تسجيلات صوتية متنوعة لتلاوات القرآن الكريم
|
| 433 |
+
من مختلف القراء والمستويات، لاستخدامها في تطوير نماذج الذكاء الاصطناعي
|
| 434 |
+
لفهم وتحليل التلاوة القرآنية.
|
| 435 |
+
</p>
|
| 436 |
+
<div style="margin-top: 20px; padding: 15px; background: #f8f9fa; border-radius: 10px;">
|
| 437 |
+
<div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
|
| 438 |
+
<span>📖 عدد الآيات المتاحة:</span>
|
| 439 |
+
<span style="font-weight: bold;">""" + str(len(ALL_AYAT)) + """</span>
|
| 440 |
+
</div>
|
| 441 |
+
<div style="display: flex; justify-content: space-between;">
|
| 442 |
+
<span>🎙️ السور المتاحة:</span>
|
| 443 |
+
<span style="font-weight: bold;">114</span>
|
| 444 |
+
</div>
|
| 445 |
+
</div>
|
| 446 |
+
</div>
|
| 447 |
+
""")
|
| 448 |
|
| 449 |
+
# قسم العرض الرئيسي
|
| 450 |
with gr.Row():
|
| 451 |
+
with gr.Column(scale=2):
|
| 452 |
with gr.Group():
|
| 453 |
+
gr.HTML("""
|
| 454 |
+
<div style="text-align: center; margin-bottom: 20px;">
|
| 455 |
+
<h2 style="color: var(--primary-color);">📖 الآية الحالية</h2>
|
| 456 |
+
<p style="color: #666;">تلاوة ثم تسجيل صوتك للآية المعروضة</p>
|
| 457 |
+
</div>
|
| 458 |
+
""")
|
| 459 |
+
|
| 460 |
curr_v = ALL_AYAT[idx_state.value]
|
| 461 |
info_text = gr.Markdown(f"### سورة {curr_v['surah_name']} - آية {curr_v['ayah']}")
|
| 462 |
text_html = gr.HTML(f"<div class='ayah-text'>{curr_v['text']}</div>")
|
| 463 |
|
| 464 |
with gr.Row():
|
| 465 |
+
with gr.Column():
|
| 466 |
+
send_btn = gr.Button("🎤 إرسال التلاوة", variant="primary", elem_classes="primary pulse")
|
| 467 |
+
with gr.Column():
|
| 468 |
+
rnd_btn = gr.Button("🔄 آية عشوائية", variant="secondary")
|
| 469 |
+
|
| 470 |
status_msg = gr.HTML("")
|
| 471 |
|
| 472 |
+
with gr.Column(scale=1):
|
| 473 |
with gr.Group():
|
| 474 |
+
gr.HTML("""
|
| 475 |
+
<div class="recording-section">
|
| 476 |
+
<h3 class="recording-title">🎙️ استوديو التسجيل</h3>
|
| 477 |
+
<p style="text-align: center; opacity: 0.9; margin-bottom: 20px;">
|
| 478 |
+
سجل تلاوتك للآية الحالية بجودة عالية
|
| 479 |
+
</p>
|
| 480 |
+
</div>
|
| 481 |
+
""")
|
| 482 |
+
audio_ui = gr.Audio(
|
| 483 |
+
sources=["microphone"],
|
| 484 |
+
type="filepath",
|
| 485 |
+
label=None,
|
| 486 |
+
waveform_options={"show_controls": True}
|
| 487 |
+
)
|
| 488 |
|
| 489 |
+
with gr.Accordion("🔍 البحث عن آية محددة", open=False):
|
| 490 |
+
with gr.Group():
|
| 491 |
+
s_drop = gr.Dropdown(
|
| 492 |
+
choices=SURAH_NAMES,
|
| 493 |
+
label="اختر السورة",
|
| 494 |
+
value="الفاتحة"
|
| 495 |
+
)
|
| 496 |
+
a_num = gr.Number(
|
| 497 |
+
label="رقم الآية",
|
| 498 |
+
value=1,
|
| 499 |
+
precision=0,
|
| 500 |
+
minimum=1
|
| 501 |
+
)
|
| 502 |
+
go_btn = gr.Button("🔍 انتقل إلى الآية", variant="primary")
|
| 503 |
+
|
| 504 |
+
# التذييل
|
| 505 |
+
gr.HTML("""
|
| 506 |
+
<footer>
|
| 507 |
+
<div class="footer-text">مِنَصَّة التِّلَاوَة - Quran Recitation Platform</div>
|
| 508 |
+
<p style="margin-top: 10px; opacity: 0.8;">
|
| 509 |
+
مشروع مفتوح المصدر يساهم في خدمة القرآن الكريم وتقنيات الذكاء الاصطناعي
|
| 510 |
+
</p>
|
| 511 |
+
<div style="margin-top: 20px; font-size: 0.9rem; opacity: 0.7;">
|
| 512 |
+
© 2024 جميع الحقوق محفوظة - للمساهمة تواصل معنا
|
| 513 |
+
</div>
|
| 514 |
+
</footer>
|
| 515 |
+
""")
|
| 516 |
|
| 517 |
+
# التعامل مع الأحداث
|
| 518 |
+
rnd_btn.click(
|
| 519 |
+
random_ayah,
|
| 520 |
+
None,
|
| 521 |
+
[text_html, info_text, idx_state, status_msg]
|
| 522 |
+
)
|
| 523 |
+
|
| 524 |
+
go_btn.click(
|
| 525 |
+
jump_logic,
|
| 526 |
+
[s_drop, a_num],
|
| 527 |
+
[status_msg, text_html, info_text, idx_state]
|
| 528 |
+
)
|
| 529 |
+
|
| 530 |
+
send_btn.click(
|
| 531 |
+
on_submit,
|
| 532 |
+
[audio_ui, idx_state, sess_state],
|
| 533 |
+
[status_msg, text_html, info_text, idx_state, sess_state, stats_display]
|
| 534 |
+
)
|
| 535 |
|
| 536 |
+
# تشغيل التطبيق
|
| 537 |
+
if __name__ == "__main__":
|
| 538 |
+
demo.launch(
|
| 539 |
+
server_name="0.0.0.0",
|
| 540 |
+
server_port=7860,
|
| 541 |
+
share=False,
|
| 542 |
+
debug=False
|
| 543 |
+
)
|