|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
model_roman = pipeline("automatic-speech-recognition", model="nairaxo/whisper-shikomori-bible") |
|
model_arabic = pipeline("automatic-speech-recognition", model="nairaxo/whisper-shikomori-bible-arabic") |
|
|
|
|
|
def transcribe(audio, model_choice): |
|
if model_choice == "Modèle en alphabet latin": |
|
transcription = model_roman(audio)["text"] |
|
else: |
|
transcription = model_arabic(audio)["text"] |
|
return transcription |
|
|
|
|
|
demo = gr.Blocks() |
|
|
|
|
|
mf_transcribe = gr.Interface( |
|
fn=transcribe, |
|
inputs=[ |
|
gr.Audio(sources=["microphone"], type="filepath", label="🎤 Entrée Audio (Microphone)"), |
|
gr.Radio(choices=["Modèle en alphabet latin", "Modèle en alphabet arabe"], label="Sélection du modèle de transcription", |
|
value="Modèle en alphabet latin", |
|
|
|
), |
|
], |
|
outputs=gr.Textbox(label="📄 Transcription en Shikomori", lines=5, max_lines=10, style={"background-color": "#F0F8FF", "font-size": "15px"}), |
|
title="Transcription Audio en Shikomori", |
|
description="<p style='color: #555;'>Sélectionnez une méthode et un modèle pour transcrire l'audio en langue Shikomori. Ce service prend en charge les transcriptions en alphabet latin et arabe.</p>", |
|
theme="compact", |
|
) |
|
|
|
|
|
file_transcribe = gr.Interface( |
|
fn=transcribe, |
|
inputs=[ |
|
gr.Audio(type="filepath", optional=True, label="📂 Entrée Audio (Fichier)"), |
|
gr.Radio(choices=["Modèle en alphabet latin", "Modèle en alphabet arabe"], label="Sélection du modèle de transcription", |
|
value="Modèle en alphabet latin", |
|
|
|
), |
|
], |
|
outputs=gr.Textbox(label="📄 Transcription en Shikomori", lines=5, max_lines=10, style={"background-color": "#F0F8FF", "font-size": "15px"}), |
|
title="Transcription Audio en Shikomori", |
|
description="<p style='color: #555;'>Chargez un fichier audio et sélectionnez un modèle pour transcrire l'audio en langue Shikomori. Transcription possible en alphabet latin ou arabe.</p>", |
|
theme="compact", |
|
) |
|
|
|
|
|
with demo: |
|
gr.TabbedInterface( |
|
[mf_transcribe, file_transcribe], |
|
["🔊 Microphone", "📁 Fichier Audio"] |
|
) |
|
|
|
|
|
|
|
|
|
demo.launch(enable_queue=True) |
|
|