File size: 691 Bytes
731a070
 
 
6fee3d5
b1447bf
 
 
731a070
 
b1447bf
 
 
 
731a070
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from transformers import pipeline
import gradio as gr

modelName = "asrnepali"
hfUser = "Hemg"



def transcribe(audio, state=""):

  modelPath = hfUser + "/" + modelName

  p = pipeline("automatic-speech-recognition", model=modelPath)
  """ Speech to text function using pipeline"""
  text = p(audio)["text"]
  state += text + " "
  return state, state
  
gr.Interface(fn=transcribe, 
  inputs=[gr.inputs.Audio(source="upload", type="filepath", label="Record/ Drop audio"), "state"], 
  outputs=["textbox", "state"], 
  title="Automatic Speech Recognition test", 
  description="Enable the recognition spoken language into text by computers.", 
  theme="huggingface", 
  live=True).launch()