Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import torch | |
| from transformers import pipeline | |
| # Chargement du pipeline ASR lié à votre modèle | |
| try: | |
| asr_pipeline = pipeline( | |
| task="automatic-speech-recognition", | |
| model="Dama12/whisper-small-moore", | |
| device=-1 # Utilisation du CPU pour le Space gratuit | |
| ) | |
| except Exception as e: | |
| asr_pipeline = None | |
| print(f"Erreur lors du chargement du modèle : {e}") | |
| def transcribe_audio(audio_path): | |
| if asr_pipeline is None: | |
| return "Erreur : Le modèle n'a pas pu être chargé." | |
| if audio_path is None: | |
| return "Veuillez enregistrer un audio ou glisser un fichier." | |
| # Exécution de la transcription | |
| prediction = asr_pipeline(audio_path) | |
| return prediction["text"] | |
| # Interface graphique Gradio | |
| demo = gr.Interface( | |
| fn=transcribe_audio, | |
| inputs=gr.Audio(sources=["microphone", "upload"], type="filepath", label="Parlez en Mooré (Micro ou Fichier)"), | |
| outputs=gr.Textbox(label="Transcription (Texte en Mooré)"), | |
| title="🎙️ Mooré Speech-to-Text", | |
| description="Démo interactive développée par Soumana Dama. Enregistrez votre voix ou déposez un fichier audio pour tester le modèle Whisper adapté au Mooré.", | |
| article="Modèle d'origine : [Dama12/whisper-small-moore](https://huggingface.co)", | |
| theme="soft" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |