File size: 586 Bytes
49524e0
face532
 
49524e0
face532
49524e0
 
 
 
 
 
 
 
 
face532
 
49524e0
 
 
 
face532
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from transformers import pipeline
import gradio as gr

model = pipeline("automatic-speech-recognition")

def transcribe_audio(mic=None, file=None):
  if mic is not None:
    audio = mic
  elif file is not None:
    audio = file
  else:
    return("You must either provide a mic recording or a file")
  transcription = model(audio)["text"]
  return transcription

gr.Interface(
  fn=transcribe_audio,
  inputs=[gr.inputs.Audio(source="microphone", type="filepath", optional=True),
          gr.inputs.Audio(source ="upload", type="filepath", optional=True)],
  outputs="text",
).launch()