Created
May 30, 2021 04:18
-
-
Save KaushikShresth07/963b7cc2ee970bdf97302700cdc7de74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyttsx3 | |
import requests | |
from googletrans import Translator | |
import speech_recognition as sr | |
engine = pyttsx3.init('sapi5') | |
voices = engine.getProperty('voices') | |
engine.setProperty('voice', voices[2].id) | |
engine.setProperty('rate',180) | |
def Speak(audio): | |
print(F": {audio}") | |
engine.say(audio) | |
engine.runAndWait() | |
print(f" ") | |
def TakeCommand(): | |
r = sr.Recognizer() | |
with sr.Microphone() as source: | |
print(": Listening....") | |
r.pause_threshold = 1 | |
audio = r.listen(source) | |
try: | |
print(": Recognizing...") | |
query = r.recognize_google(audio,language='hi') | |
print(f": Your Command : {query}\n") | |
except: | |
return "" | |
return query.lower() | |
def TaskExe(): | |
while True: | |
queryHindi = TakeCommand() | |
if 'हेलो' in queryHindi: | |
Speak("नमस्ते सर आप कैसे हो ?") | |
elif 'आप कैसे हैं' in queryHindi: | |
Speak("मैं ठीक जार्विस") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment