Created
May 25, 2021 05:09
-
-
Save KaushikShresth07/aa832b43c3c0d7087b604cf24f1990e1 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 speech_recognition as sr | |
| engine = pyttsx3.init('sapi5') | |
| voices = engine.getProperty('voices') | |
| engine.setProperty('voice', voices[7].id) | |
| engine.setProperty('rate',170) | |
| def Speak(Audio): | |
| print(" ") | |
| print(f": {Audio}") | |
| engine.say(Audio) | |
| print(" ") | |
| engine.runAndWait() | |
| def takecommand(): | |
| r = sr.Recognizer() | |
| with sr.Microphone() as source: | |
| print(" ") | |
| print("Listening...") | |
| r.pause_threshold = 1 | |
| audio = r.listen(source) | |
| try: | |
| print("Recognizing...") | |
| query = r.recognize_google(audio, language='en-in') | |
| print(f"Your Command : {query}\n") | |
| except: | |
| return "None" | |
| return query.lower() | |
| def TaskExe(): | |
| while True: | |
| query = takecommand() | |
| if 'hello' in query: | |
| Speak("Hello Sir , How Are You ?") | |
| else: | |
| Speak("No Command Found!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment