Spaces:
Sleeping
Sleeping
Create wne123
Browse files
wne123
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# تعريف النماذج
|
| 4 |
+
models = {
|
| 5 |
+
"Whisper Small": "openai/whisper-small.en",
|
| 6 |
+
"Wav2Vec2": "facebook/wav2vec2-base-960h"
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
# تحميل النماذج من Hugging Face
|
| 10 |
+
whisper = gr.Interface.load(f"huggingface/{models['Whisper Small']}")
|
| 11 |
+
wav2vec = gr.Interface.load(f"huggingface/{models['Wav2Vec2']}")
|
| 12 |
+
|
| 13 |
+
# دالة تحويل الصوت لنص باستخدام النموذجين
|
| 14 |
+
def transcribe_with_all(audio_path):
|
| 15 |
+
whisper_result = whisper(audio_path)
|
| 16 |
+
wav2vec_result = wav2vec(audio_path)
|
| 17 |
+
return whisper_result, wav2vec_result
|
| 18 |
+
|
| 19 |
+
# واجهة المقارنة باستخدام Gradio
|
| 20 |
+
with gr.Blocks() as demo:
|
| 21 |
+
gr.Markdown("# 🗣️ Speech Recognition Model Comparison")
|
| 22 |
+
gr.Markdown("قارن بين نتائج تحويل الصوت إلى نص من نموذجين مختلفين")
|
| 23 |
+
|
| 24 |
+
audio_input = gr.Audio(type="filepath", label="🎧 أدخل ملف صوتي")
|
| 25 |
+
|
| 26 |
+
transcribe_btn = gr.Button("🔍 حوّل النص")
|
| 27 |
+
|
| 28 |
+
with gr.Row():
|
| 29 |
+
with gr.Column():
|
| 30 |
+
gr.Markdown("### Whisper Small (OpenAI)")
|
| 31 |
+
whisper_output = gr.Textbox(label="النص الناتج من Whisper")
|
| 32 |
+
with gr.Column():
|
| 33 |
+
gr.Markdown("### Wav2Vec2 (Facebook)")
|
| 34 |
+
wav2vec_output = gr.Textbox(label="النص الناتج من Wav2Vec2")
|
| 35 |
+
|
| 36 |
+
transcribe_btn.click(
|
| 37 |
+
fn=transcribe_with_all,
|
| 38 |
+
inputs=audio_input,
|
| 39 |
+
outputs=[whisper_output, wav2vec_output]
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
# تشغيل التطبيق
|
| 43 |
+
demo.launch()
|