import gradio, requests, os API_URL = os.environ["API_URL"] HEADERS = { "Content-Type": "audio/wave", "Authorization": os.environ["TOKEN"] } def transcribe(audio): try: with open(audio, "rb") as file: data = file.read() response = requests.post(API_URL, headers=HEADERS, data=data) return response.json()["text"] except: return "AI model was sleeping and a request has been sent to wake it up. Please try again after 60 sec." gradio.Interface( fn=transcribe, inputs=gradio.Audio(type="filepath", max_length=30, sources="microphone", format="wav"), outputs="label", title="Model trained to recognise Panjabi speech (you might face issue with your mic, please refresh page to properly record your voice}", ).launch()