-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTTE-Code.py
More file actions
28 lines (24 loc) · 936 Bytes
/
Copy pathSTTE-Code.py
File metadata and controls
28 lines (24 loc) · 936 Bytes
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
import os
import speech_recognition as sr
#After importing the speech recognition module then next step is to initialize
#the speech which I mentioned in function as below
def main():
r = sr.Recognizer()
#Now the speech is going to use online recogniser
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source)
print("Hi, which shell command do you want to execute ? ")
#Now we should give speech input and going to listening
audio = r.listen(source)
#Here using recognizer to convert into text as well as to execute
#the input shell command
try:
r1=r.recognize_google(audio)
print("You said : \n "+r1)
os.system("{t1}".format(t1=r1))
print("Okay")
except Exception as e:
print("Error : " + str(e))
#calling main function
if __name__=="__main__":
main()