Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
from transformers import
|
2 |
-
import torch
|
3 |
-
import gradio as gr
|
4 |
|
5 |
-
|
6 |
-
|
|
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
def transcribe(audio):
|
9 |
-
|
10 |
-
|
11 |
-
logits = model(input_values).logits
|
12 |
-
predicted_ids = torch.argmax(logits, dim=-1)
|
13 |
-
transcription = tokenizer.batch_decode(predicted_ids)[0]
|
14 |
-
return transcription
|
15 |
|
16 |
iface = gr.Interface(
|
17 |
fn=transcribe,
|
@@ -19,4 +19,4 @@ iface = gr.Interface(
|
|
19 |
outputs="text"
|
20 |
)
|
21 |
|
22 |
-
iface.launch()
|
|
|
1 |
+
from transformers import pipeline, AutoTokenizer
|
|
|
|
|
2 |
|
3 |
+
# Spécifiez le nom du modèle et le jeton d'authentification
|
4 |
+
model_name = "BenDaouda/wav2vec2-large-xls-r-300m-wolof-test-coloab"
|
5 |
+
token = "votre-jeton-d'authentification-hugging-face"
|
6 |
|
7 |
+
# Chargez le modèle et le tokenizer en utilisant le jeton d'authentification
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=True)
|
9 |
+
model = pipeline("automatic-speech-recognition", model=model_name, tokenizer=tokenizer, task="asr", use_auth_token=True)
|
10 |
+
|
11 |
+
# Utilisez la fonction Gradio avec votre modèle chargé
|
12 |
def transcribe(audio):
|
13 |
+
result = model(audio)
|
14 |
+
return result[0]['text']
|
|
|
|
|
|
|
|
|
15 |
|
16 |
iface = gr.Interface(
|
17 |
fn=transcribe,
|
|
|
19 |
outputs="text"
|
20 |
)
|
21 |
|
22 |
+
iface.launch()
|