Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,11 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from gradio_client import Client, handle_file
|
| 4 |
-
from
|
| 5 |
|
| 6 |
-
# 1. الربط بالخزنة (المساحة الخاصة)
|
| 7 |
-
# تأكد من وضع الـ Token في الـ Settings -> Secrets باسم HF_TOKEN
|
| 8 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 9 |
client = Client("aboalaa1472/Quran_ASR", hf_token=HF_TOKEN)
|
| 10 |
|
| 11 |
-
# تجهيز قائمة السور بالشكل الذي يتوقعه الـ API (مثلاً: "1 - الفاتحة")
|
| 12 |
SURAH_CHOICES = [f"{num} - {name}" for num, name in QURAN_SURAHS.items()]
|
| 13 |
|
| 14 |
def process_quran_asr(audio_input, surah_choice):
|
|
@@ -16,8 +13,6 @@ def process_quran_asr(audio_input, surah_choice):
|
|
| 16 |
return "برجاء رفع ملف صوتي أو التسجيل", None, None, None, None
|
| 17 |
|
| 18 |
try:
|
| 19 |
-
# إرسال الطلب للـ Private Space
|
| 20 |
-
# بنمرر audio_input للـ uploaded والـ mic عشان الـ API طالب الاتنين
|
| 21 |
result = client.predict(
|
| 22 |
uploaded_audio=handle_file(audio_input),
|
| 23 |
mic_audio=handle_file(audio_input),
|
|
@@ -37,7 +32,7 @@ with gr.Blocks(title="نظام تصحيح التلاوة") as demo:
|
|
| 37 |
with gr.Column():
|
| 38 |
audio_in = gr.Audio(
|
| 39 |
label="🎙️ سجل صوتك أو ارفع ملف",
|
| 40 |
-
type="filepath"
|
| 41 |
)
|
| 42 |
surah_dropdown = gr.Dropdown(
|
| 43 |
choices=SURAH_CHOICES,
|
|
@@ -55,7 +50,6 @@ with gr.Blocks(title="نظام تصحيح التلاوة") as demo:
|
|
| 55 |
out_verses = gr.File(label="📖 نص الآيات المكتشفة")
|
| 56 |
out_original = gr.File(label="💾 ملف النص الأصلي")
|
| 57 |
|
| 58 |
-
# ربط الزر بالدالة
|
| 59 |
btn.click(
|
| 60 |
fn=process_quran_asr,
|
| 61 |
inputs=[audio_in, surah_dropdown],
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from gradio_client import Client, handle_file
|
| 4 |
+
from surahs_list import QURAN_SURAHS
|
| 5 |
|
|
|
|
|
|
|
| 6 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 7 |
client = Client("aboalaa1472/Quran_ASR", hf_token=HF_TOKEN)
|
| 8 |
|
|
|
|
| 9 |
SURAH_CHOICES = [f"{num} - {name}" for num, name in QURAN_SURAHS.items()]
|
| 10 |
|
| 11 |
def process_quran_asr(audio_input, surah_choice):
|
|
|
|
| 13 |
return "برجاء رفع ملف صوتي أو التسجيل", None, None, None, None
|
| 14 |
|
| 15 |
try:
|
|
|
|
|
|
|
| 16 |
result = client.predict(
|
| 17 |
uploaded_audio=handle_file(audio_input),
|
| 18 |
mic_audio=handle_file(audio_input),
|
|
|
|
| 32 |
with gr.Column():
|
| 33 |
audio_in = gr.Audio(
|
| 34 |
label="🎙️ سجل صوتك أو ارفع ملف",
|
| 35 |
+
type="filepath"
|
| 36 |
)
|
| 37 |
surah_dropdown = gr.Dropdown(
|
| 38 |
choices=SURAH_CHOICES,
|
|
|
|
| 50 |
out_verses = gr.File(label="📖 نص الآيات المكتشفة")
|
| 51 |
out_original = gr.File(label="💾 ملف النص الأصلي")
|
| 52 |
|
|
|
|
| 53 |
btn.click(
|
| 54 |
fn=process_quran_asr,
|
| 55 |
inputs=[audio_in, surah_dropdown],
|