Skip to content

Instantly share code, notes, and snippets.

@KaushikShresth07
Created June 12, 2021 13:34
Show Gist options
  • Select an option

  • Save KaushikShresth07/0ca455e4a6f0aff1f5c77e31241dbc79 to your computer and use it in GitHub Desktop.

Select an option

Save KaushikShresth07/0ca455e4a6f0aff1f5c77e31241dbc79 to your computer and use it in GitHub Desktop.
import speech_recognition as sr
from googletrans import Translator # pip install googletrans==3.1.0a0
def TakeHindi():
command = sr.Recognizer()
with sr.Microphone() as source:
print("Listening......")
command.pause_threshold = 1
audio = command.listen(source)
try:
print("Recognizing.....")
query = command.recognize_google(audio,language='hi')
print(f"You Said : {query}")
except:
return "none"
return query.lower()
def Tran():
line = TakeHindi()
traslate = Translator()
result = traslate.translate(line)
Text = result.text
return Text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment