Skip to content

Commit

Permalink
refactor(cognitive-services): add continue keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
FergusKidd committed Jul 5, 2021
1 parent 0577a58 commit e6cfbe2
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions control-agent/text-to-speech/speech-detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,6 @@ def vision_intent():
speech.speak("I can see" + str(result["description"]["captions"][0]["text"]))


def joke_intent():
"""Reads aloud a joke, as an example of a data
lookup with an external API"""
speech.speak("ok - let me think of one")

url = "https://v2.jokeapi.dev/joke/Programming"
query = {"type": "twopart", "blacklistFlags": "nsfw"}
response = requests.get(url, params=query)

speech.speak(response.json()["setup"])
speech.speak(response.json()["delivery"])


def intent_handler(intent):
"""Handles the intent responces and calls the associated fucntions"""

Expand Down Expand Up @@ -380,8 +367,6 @@ def intent_handler(intent):
arm_intent(intent)
elif intent.intent_id == "Wrist":
wrist_intent()
elif intent.intent_id == "Joke":
joke_intent()

return True

Expand All @@ -393,9 +378,10 @@ def intent_handler(intent):
# start camera
realsense = Realsense()


while run == True:

intent = recognize_intent()

run = intent_handler(intent)

continue

0 comments on commit e6cfbe2

Please sign in to comment.