import speech_recognition as sr from httpcore import SyncHTTPProxy from googletrans import Translator """ http_proxy = SyncHTTPProxy((b'http', b'myproxy.com', 8080, b'')) proxies = {'http': http_proxy, 'https': http_proxy } def transcribeHindi(): r = sr.Recognizer() with sr.Microphone() as source: # seconds of non-speaking audio before # a phrase is considered complete print('Listening') r.pause_threshold = 0.7 audio = r.listen(source) try: print("Recognizing") Query = r.recognize_google(audio, language='hi-In') # for listening the command in indian english print("the query is printed='", Query, "'") # handling the exception, so that assistant can # ask for telling again the command except Exception as e: print(e) print("Say that again sir") return "None" return Query def translate(): query = transcribeHindi() translator = Translator() translation = translator.translate(query, dest='en') return translation.text gr.Interface( fn=translate, inputs=gr.Audio(source="microphone", type="numpy"), outputs="text").launch() """ def transcribe(audio): text = p(audio)["text"] return text gr.Interface( fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text").launch()