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()