File size: 1,510 Bytes
82b0ff6 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import gradio as gr
# تعريف النماذج
models = {
"Whisper Small": "openai/whisper-small.en",
"Wav2Vec2": "facebook/wav2vec2-base-960h"
}
# تحميل النماذج من Hugging Face
whisper = gr.Interface.load(f"huggingface/{models['Whisper Small']}")
wav2vec = gr.Interface.load(f"huggingface/{models['Wav2Vec2']}")
# دالة تحويل الصوت لنص باستخدام النموذجين
def transcribe_with_all(audio_path):
whisper_result = whisper(audio_path)
wav2vec_result = wav2vec(audio_path)
return whisper_result, wav2vec_result
# واجهة المقارنة باستخدام Gradio
with gr.Blocks() as demo:
gr.Markdown("# 🗣️ Speech Recognition Model Comparison")
gr.Markdown("قارن بين نتائج تحويل الصوت إلى نص من نموذجين مختلفين")
audio_input = gr.Audio(type="filepath", label="🎧 أدخل ملف صوتي")
transcribe_btn = gr.Button("🔍 حوّل النص")
with gr.Row():
with gr.Column():
gr.Markdown("### Whisper Small (OpenAI)")
whisper_output = gr.Textbox(label="النص الناتج من Whisper")
with gr.Column():
gr.Markdown("### Wav2Vec2 (Facebook)")
wav2vec_output = gr.Textbox(label="النص الناتج من Wav2Vec2")
transcribe_btn.click(
fn=transcribe_with_all,
inputs=audio_input,
outputs=[whisper_output, wav2vec_output]
)
# تشغيل التطبيق
demo.launch()
|