File size: 817 Bytes
fa7931e
8ea39df
62289a0
fa7931e
62289a0
 
 
 
 
8ea39df
 
bba37db
 
8ea39df
 
bba37db
 
 
 
8ea39df
 
bba37db
8ea39df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from transformers import pipeline
from transformers import AutoTokenizer

# Create a PretrainedTokenizer object
tokenizer = AutoTokenizer.from_pretrained('wannaphong/wav2vec2-large-xlsr-53-th-cv8-deepcut')

# Pass the PretrainedTokenizer object as the tokenizer argument
p = pipeline('text-generation', model='wannaphong/wav2vec2-large-xlsr-53-th-cv8-deepcut', tokenizer=tokenizer)

def transcribe(audio):
    # Pass the audio file to the pipeline and obtain the output
    text = p(audio)["generated_text"]
    return text
    
# Create a GraudioInput object for the audio input
audio_input = gr.Audio(source="microphone", type="filepath")

# Use the GraudioInput object as the value for the inputs argument
gr.Interface(
    fn=transcribe, 
    inputs=audio_input, 
    outputs="text").launch()