Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from google import genai
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 6 |
+
|
| 7 |
+
def diacritize(text):
|
| 8 |
+
|
| 9 |
+
prompt = f"""
|
| 10 |
+
أضف التشكيل الكامل للنص العربي التالي مع مراعاة المعنى:
|
| 11 |
+
|
| 12 |
+
{text}
|
| 13 |
+
|
| 14 |
+
أعد النص فقط بعد التشكيل بدون أي شرح.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
response = client.models.generate_content(
|
| 18 |
+
model="gemini-2.5-flash",
|
| 19 |
+
contents=prompt
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
return response.text
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
demo = gr.Interface(
|
| 26 |
+
fn=diacritize,
|
| 27 |
+
inputs=gr.Textbox(lines=6, label="Input Text"),
|
| 28 |
+
outputs=gr.Textbox(label="Diacritized Text"),
|
| 29 |
+
title="Arabic Diacritization API"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
demo.launch()
|