File size: 1,084 Bytes
8290384 e16eb92 8290384 e16eb92 8290384 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import gradio as gr
from transformers import pipeline
# تحميل النموذج الجاهز من Hugging Face
accent_classifier = pipeline("audio-classification", model="Yactayo/AccentClassifier")
def classify_accent(audio_path):
try:
results = accent_classifier(audio_path)
top_result = results[0]
label = top_result["label"]
score = round(top_result["score"] * 100, 2)
return f"{label} ({score}%)"
except Exception as e:
return f"Error: {str(e)}"
# واجهة Gradio
with gr.Blocks() as demo:
gr.Markdown("## 🎙️ تصنيف اللهجات باستخدام AI")
with gr.Row():
audio_input = gr.Audio(type="filepath", label="🔊 سجل أو حمّل ملف صوتي", sources=["upload", "microphone"])
output_text = gr.Textbox(label="اللهجة المتوقعة")
analyze_btn = gr.Button("🔍 تحليل اللهجة")
analyze_btn.click(fn=classify_accent, inputs=audio_input, outputs=output_text)
# تشغيل التطبيق
if __name__ == "__main__":
demo.launch()
|