File size: 503 Bytes
f37ac06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
import speech_recognition as sr

def transcribe(filename):
    r = sr.Recognizer()

    with sr.AudioFile(filename) as source:
        # listen for the data (load audio to memory)
        audio_data = r.record(source)
        # recognize (convert from speech to text)
        text = r.recognize_google(audio_data)
        
        return text

demo = gr.Interface(
    transcribe,
    [gr.Audio(type="filepath")],
    "textbox",
)
demo.launch(server_name="0.0.0.0", server_port=7860)