with slot example

This commit is contained in:
Patrice 2019-04-15 21:23:08 +02:00
parent 5e57d6d9b7
commit 517db5be29
5 changed files with 64 additions and 16 deletions

0
.vscode/launch.json vendored Normal file
View File

BIN
ngrok.exe Normal file

Binary file not shown.

View File

@ -12,11 +12,11 @@ logging.getLogger('flask_ask').setLevel(logging.DEBUG)
@ask.launch
def launch():
return question("This will take about 5 minutes. Are you Ready?")
return question("Each excercise will take about 5 minutes. Are you Ready?")
def get_workoutplan():
with open("workouts.yaml", 'r') as stream:
with open("C:/Users/John/Desktop/GST/samples/reddit/workouts.yaml", 'r') as stream:
exercises = yaml.load(stream)
exercise_names = random.sample(list(exercises), 5)
workout_plan = []
@ -26,14 +26,17 @@ def get_workoutplan():
return workout_plan
@ask.intent('YesIntent')
def start_workout():
@ask.intent('YesIntent', mapping={'part': 'Part'})
def start_workout(part):
print(part)
workout_plan = get_workoutplan()
response = ""
response = "Do "
for excercise in workout_plan[:-1]:
response += excercise + ", "
response += " and " + workout_plan[-1]
return statement(workout_plan)
print(response)
return statement(response)
@ask.intent('NoIntent')
def no():
@ -44,6 +47,7 @@ def help():
speech_text = 'If you want a quick workout just say "workout"'
return statement(speech_text)
@ask.session_ended
def session_ended():
return "{}", 200
@ -54,4 +58,4 @@ if __name__ == '__main__':
verify = str(os.environ.get('ASK_VERIFY_REQUESTS', '')).lower()
if verify == 'false':
app.config['ASK_VERIFY_REQUESTS'] = False
app.run(debug=True)
app.run()

View File

@ -1,10 +1,50 @@
{
"interactionModel": {
"languageModel": {
"invocationName": "give me a workout",
"intents": [
{
"intent": "HelloWorldIntent"
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"intent": "AMAZON.HelpIntent"
}
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "YesIntent",
"slots": [],
"samples": [
"yes"
]
},
{
"name": "NoIntent",
"slots": [],
"samples": [
"no"
]
},
{
"name": "HelloWorldIntent",
"slots": [],
"samples": [
"let's workout",
"give me todays workout",
"what's todays workout"
]
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
}
],
"types": []
}
}
}

View File

@ -0,0 +1,4 @@
Chest
Legs
Torso
Upper body