File size: 541 Bytes
b94ad4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-


import gradio as gr
from transformers import pipeline

asr = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-100h")

def transcribe_audio(audio):
    text = asr(audio)["text"]
    return text

demo = gr.Interface(
    fn=transcribe_audio,
    inputs=gr.Audio(sources=["microphone"], type="filepath"),
    outputs="text",
    title="Speech-to-Text Transcription",
    description="Record your voice and get the transcribed text using a pre-trained Wav2Vec2 model."
)

demo.launch(share=True)