Spaces:
Sleeping
Sleeping
MAJED94760
commited on
Commit
•
f57bfa0
1
Parent(s):
10adbf5
Create app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,41 @@
|
|
1 |
import gradio as gr
|
2 |
from gtts import gTTS
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Create Gradio interface
|
11 |
iface = gr.Interface(
|
12 |
-
fn=
|
13 |
-
inputs=
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
],
|
18 |
outputs="audio",
|
19 |
-
title="
|
20 |
-
description="
|
21 |
)
|
22 |
|
23 |
# Launch the interface
|
|
|
1 |
import gradio as gr
|
2 |
from gtts import gTTS
|
3 |
|
4 |
+
# تعريف الحكم
|
5 |
+
arabic_proverbs = [
|
6 |
+
"الصبر مفتاح الفرج.",
|
7 |
+
"الوقت كالسيف إن لم تقطعه قطعك.",
|
8 |
+
"العقل زينة."
|
9 |
+
]
|
10 |
+
|
11 |
+
english_proverbs = [
|
12 |
+
"Patience is a virtue.",
|
13 |
+
"Time is money.",
|
14 |
+
"Knowledge is power."
|
15 |
+
]
|
16 |
+
|
17 |
+
def get_proverb(language):
|
18 |
+
if language == "Arabic":
|
19 |
+
proverb = arabic_proverbs[0] # يمكن تعديل الاختيار بشكل عشوائي أو حسب اختيار المستخدم
|
20 |
+
elif language == "English":
|
21 |
+
proverb = english_proverbs[0] # يمكن تعديل الاختيار بشكل عشوائي أو حسب اختيار المستخدم
|
22 |
+
else:
|
23 |
+
proverb = "Invalid choice"
|
24 |
+
|
25 |
+
tts = gTTS(text=proverb, lang='ar' if language == "Arabic" else 'en')
|
26 |
+
tts.save("proverb.mp3")
|
27 |
+
return "proverb.mp3"
|
28 |
|
29 |
# Create Gradio interface
|
30 |
iface = gr.Interface(
|
31 |
+
fn=get_proverb,
|
32 |
+
inputs=gr.Dropdown(
|
33 |
+
choices=["Arabic", "English"],
|
34 |
+
label="اختر نوع الحكمة"
|
35 |
+
),
|
|
|
36 |
outputs="audio",
|
37 |
+
title="حكم صوتية",
|
38 |
+
description="اختر نوع الحكمة لتلقيها بصوت مولد بالذكاء الاصطناعي."
|
39 |
)
|
40 |
|
41 |
# Launch the interface
|