File size: 805 Bytes
832feba
1f855d9
832feba
 
 
1f855d9
832feba
 
 
 
 
5f34871
832feba
 
5f34871
 
 
 
 
314bad3
1f855d9
832feba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from transformers import pipeline, AutoTokenizer

# Spécifiez le nom du modèle et le jeton d'authentification
model_name = "BenDaouda/wav2vec2-large-xls-r-300m-wolof-test-coloab"
token = "votre-jeton-d'authentification-hugging-face"

# 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, task="asr", use_auth_token=True)

# Utilisez la fonction Gradio avec votre modèle chargé
def transcribe(audio):
    result = model(audio)
    return result[0]['text']

iface = gr.Interface(
    fn=transcribe,
    inputs=gr.inputs.Audio(source="microphone", type="file", resample_to=16000),
    outputs="text"
)

iface.launch()