-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
36 lines (29 loc) · 861 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import pyttsx3
import speech_recognition as sr
from subprocess import call
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def speak(text):
engine.say(text)
engine.runAndWait()
def takecommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
speak("Listening...")
r.pause_threshold=1
audio = r.listen(source)
try:
print("Recognizing...")
speak("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"user said:{query}\n")
except Exception as e:
return "None"
return query
if __name__ == "__main__":
query=takecommand().lower()
if "activate" in query:
call(["python","Naina.py"])