Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import speech_recognition as sr
- import pyttsx3
- import os
- engine = pyttsx3.init()
- r = sr.Recognizer()
- print("Please Talk")
- with sr.Microphone() as source:
- r.adjust_for_ambient_noise(source)
- while True:
- #print(sr.Microphone())
- #audio_data=r.record(source,duration=5)
- audio_data = r.listen(source)
- #audio_data = r.adjust_for_ambient_noise(source, duration=5)
- print("Recognizing...")
- text = ""
- try:
- text = r.recognize_google(audio_data)
- except:
- print("## could not recognize")
- #print("")
- print(text)
- if "hello Jarvis" in text:
- print("Hello Sourav")
- engine.say("Hello Sourav")
- engine.runAndWait()
- if "open" in text.lower() and "chrome" in text.lower():
- print("Opening chrome...")
- engine.say("Opening chrome...")
- engine.runAndWait()
- os.system("\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"")
- if "stop"==text:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement