File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
AutomationScripts/Speech Recognizer Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ import pyttsx3
2
+ import speech_recognition as sr
3
+
4
+
5
+ engine = pyttsx3 .init ()
6
+
7
+
8
+ def fun_talk (audio ):
9
+ engine .say (audio )
10
+ engine .runAndWait ()
11
+
12
+
13
+ def get_command ():
14
+
15
+ rec = sr .Recognizer ()
16
+ with sr .Microphone () as source :
17
+ print ("Say something..." )
18
+ rec .pause_threshold = 1
19
+
20
+ audio = rec .listen (source )
21
+
22
+ try :
23
+ print ("Recognizing..." )
24
+ command = rec .recognize_google (audio , language = 'en-in' )
25
+ print (f"You said: { command } \n " )
26
+ fun_talk (f"You said: { command } \n " )
27
+
28
+ except Exception as e :
29
+ # print(e)
30
+ print ("Say that again please..." )
31
+ return "None"
32
+
33
+ return command
34
+
35
+
36
+ if __name__ == '__main__' :
37
+
38
+ if 1 :
39
+
40
+ query = get_command ().lower ()
You can’t perform that action at this time.
0 commit comments