BenDaouda's picture
Update app.py
257dbc1
raw
history blame
No virus
865 Bytes
from transformers import pipeline, AutoTokenizer
from huggingface_hub import login
import gradio as gr
login('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')
# Spécifiez le nom du modèle et le jeton d'authentification
model_name = "BenDaouda/wav2vec2-large-xls-r-300m-wolof-test-coloab"
token = "vhf_IwkuGBEkyipKSnyJzJcCRSwOSJDvNivOmH"
# Chargez le modèle et le tokenizer en utilisant le jeton d'authentification
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=True)
model = pipeline("automatic-speech-recognition", model=model_name, tokenizer=tokenizer, use_auth_token=True)
# Utilisez la fonction Gradio avec votre modèle chargé
def transcribe(audio):
result = model(audio)["text"]
return result
iface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="filepath"),
outputs="text"
)
iface.launch()