MCPcopy Index your code
hub / github.com/geekcomputers/Python / voice_loop

Function voice_loop

JARVIS/cli.py:99–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97
98
99def voice_loop():
100 say("Ready.")
101 print("Listening stays on. Speak when you want something, or say 'type mode' to write.")
102 check_lm_studio()
103 apps = build_application_index()
104 say(f"Safe app index ready: {len(apps)} apps found.")
105
106 recognizer = sr.Recognizer()
107 recognizer.pause_threshold = 2
108 recognizer.non_speaking_duration = 1
109
110 try:
111 with sr.Microphone() as source:
112 print("Calibrating microphone...")
113 recognizer.adjust_for_ambient_noise(source, duration=1)
114 while True:
115 user_input = listen_once(recognizer, source, choose_best_candidate)
116 if not user_input:
117 print("No clear speech detected. Continuing to listen...")
118 continue
119 if should_exit(user_input):
120 say("Goodbye.")
121 break
122 if wants_type_mode(user_input):
123 typed = input("Type to Jarvis: ").strip()
124 if typed:
125 print(f"You typed: {typed}")
126 if should_exit(typed):
127 say("Goodbye.")
128 break
129 handle_and_say(typed)
130 print("Listening again...")
131 continue
132 if normalize_text(user_input) in {"refresh apps", "uygulamalari yenile", "uygulamaları yenile"}:
133 apps = build_application_index()
134 say(f"Safe app index refreshed: {len(apps)} apps found.")
135 continue
136 handle_and_say(user_input)
137 except KeyboardInterrupt:
138 print()
139 say("Goodbye.")
140 except Exception as exc:
141 say(f"Microphone error: {exc}")
142 print("Falling back to type mode.")
143 typed_loop()
144
145
146def typed_loop():

Callers 2

typed_loopFunction · 0.85
mainFunction · 0.85

Calls 9

sayFunction · 0.85
check_lm_studioFunction · 0.85
build_application_indexFunction · 0.85
listen_onceFunction · 0.85
should_exitFunction · 0.85
wants_type_modeFunction · 0.85
handle_and_sayFunction · 0.85
normalize_textFunction · 0.85
typed_loopFunction · 0.85

Tested by

no test coverage detected