MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / takeCommand

Function takeCommand

desktopassistant/index.py:36–54  ·  view source on GitHub ↗

It takes microphone input from the user and returns string output

()

Source from the content-addressed store, hash-verified

34 speak("Good night")
35 speak("Hello I am your personal desktop assistant. Please tell me how may i help you ")
36def takeCommand():
37 '''It takes microphone input from the user and returns string output'''
38 r=sr.Recognizer()
39 with sr.Microphone() as source:
40 speak("Go Ahead, I am listening to you......")
41 print("Go Ahead, I am listening to you......")
42 r.pause_threshold = 1
43 audio=r.listen(source)
44
45 try:
46 print("Recognizing")
47
48 query=r.recognize_google(audio, language='hi-in')
49 print(f"User said:{query}\n")
50 except Exception as e:
51 #print(e)
52 speak("sorry i can't able to hear you Say that again please....")
53 return "None"
54 return query
55
56
57

Callers 1

index.pyFile · 0.85

Calls 1

speakFunction · 0.85

Tested by

no test coverage detected