// Exit recognition if any of the transcribed phrases could be
// one of our keywords.
if any(alt.confidence > .5 and
(alt.transcript.strip() in ("exit", "quit"))
for result in resp.results
for alt in result.alternatives):
print("Exiting..")
After Change
// Exit recognition if any of the transcribed phrases could be
// one of our keywords.
if any(re.search(r"\b(exit|quit)\b", alt.transcript)
for result in resp.results
for alt in result.alternatives):
print("Exiting..")
return