Spaces:
Sleeping
Sleeping
File size: 673 Bytes
67965ba 9e8a040 320e714 67965ba 9f95d71 f808091 e09db0a 396b569 f808091 396b569 f808091 396b569 f808091 544503f 8c8ff11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import os
import gradio as gr
os.system("sudo apt-get update")
os.system("apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg")
# import sounddevice as sd
import speech_recognition as sr
recognizer = sr.Recognizer()
def translate(audio_path:str,lang:str):
with sr.AudioFile(audio_path) as source:
audio = recognizer.record(source)
try:
spoken_text = recognizer.recognize_google(audio,language=lang)
return spoken_text
except:
gr.Error("some error rised")
k=gr.Interface(fn=translate, inputs=[gr.Audio(source="upload", type="filepath"),gr.Text(label="lang")], outputs="text")
k.launch() |