File size: 596 Bytes
a469909
c2b5789
 
 
 
f2be7cd
c2b5789
 
 
 
a469909
 
 
 
 
 
3f5ff90
06ed778
3f5ff90
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline, AutoModelForCTC, AutoTokenizer

# Load the model from PyTorch weights
model_name = "facebook/wav2vec2-large-xlsr-53-spanish"
model = AutoModelForCTC.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Create the ASR pipeline
trans = pipeline("automatic-speech-recognition", model=model, tokenizer=tokenizer)


def audio2text(audio):
  text = trans(audio)["text"]
  return text

gr.Interface(
    fn=audio2text,
    inputs = [gr.Audio(source="microphone", type="filepath")],
    outputs=["textbox"]
).launch()