File size: 683 Bytes
e59b53b
 
4e7301a
032afb0
 
 
 
 
 
 
4e7301a
032afb0
 
 
4e7301a
032afb0
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from transformers import pipeline

# Load the automatic speech recognition pipeline
asr_pipeline = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-960h")

def transcribe_audio(audio):
    # Transcribe the audio input
    transcription = asr_pipeline(audio)[0]["transcription"]
    return transcription

# Define Gradio interface
audio_input = gr.inputs.Audio(source="microphone", type="auto", label="Record Audio")
text_output = gr.outputs.Textbox(label="Transcription")

# Create the interface and launch it
interface = gr.Interface(fn=transcribe_audio, inputs=audio_input, outputs=text_output, title="Speech to Text")
interface.launch()