Spaces:
Build error
Build error
| from speechbrain.inference.ASR import EncoderASR | |
| import gradio as gr | |
| import numpy as np | |
| import soundfile as sf | |
| model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof") | |
| def transcribe(audio): | |
| if isinstance(audio, str): # Si audio est un chemin de fichier | |
| return model.transcribe_file(audio) | |
| else: # Si audio est un tuple (cas du microphone) | |
| sr, y = audio | |
| y = y.astype(np.float32) | |
| y /= np.max(np.abs(y)) | |
| # Enregistrer temporairement l'audio pour utiliser la méthode transcribe_file | |
| temp_file = 'temp.wav' | |
| sf.write(temp_file, y, sr) | |
| return model.transcribe_file(temp_file) | |
| demo = gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.Audio(sources=["microphone", "upload"], label="Audio en wolof"), | |
| outputs=gr.Textbox(label="Transcription alphabet latin"), | |
| title="Transcription audio en wolof latin by PSW", | |
| description="Ce modèle transcrit un fichier audio en wolof en texte en utilisant l'alphabet latin." | |
| ) | |
| demo.launch() | |