added excersie example

This commit is contained in:
Patrice 2019-04-14 15:07:54 +02:00
parent 678727369e
commit 5e57d6d9b7
3 changed files with 98 additions and 12 deletions

View File

@ -2,7 +2,8 @@ import logging
import os
from flask import Flask
from flask_ask import Ask, request, session, question, statement
import random
import yaml
app = Flask(__name__)
ask = Ask(app, "/")
@ -11,28 +12,37 @@ logging.getLogger('flask_ask').setLevel(logging.DEBUG)
@ask.launch
def launch():
speech_text = 'Welcome to the Alexa Skills Kit, you can say hello'
return question("how ya doin?")
return question("This will take about 5 minutes. Are you Ready?")
@ask.intent('HelloWorldIntent')
def hello_world():
return "Hello"
def get_workoutplan():
with open("workouts.yaml", 'r') as stream:
exercises = yaml.load(stream)
exercise_names = random.sample(list(exercises), 5)
workout_plan = []
for exercise_name in exercise_names:
exercise = str(exercises[exercise_name]["duration"][0]) + " " + str(exercises[exercise_name]["duration"][1] )+ " of " + exercise_name
workout_plan.append(exercise)
return workout_plan
@ask.intent('YesIntent')
def share_headlines():
return statement("the world is shit")
def start_workout():
workout_plan = get_workoutplan()
response = ""
for excercise in workout_plan[:-1]:
response += excercise + ", "
response += " and " + workout_plan[-1]
return statement(workout_plan)
@ask.intent('NoIntent')
def no():
return statement("the world is shit")
return statement("Allright, maybe later.")
@ask.intent('AMAZON.HelpIntent')
def help():
speech_text = 'You can say hello to me!'
return question(speech_text).reprompt(speech_text).simple_card('HelloWorld', speech_text)
speech_text = 'If you want a quick workout just say "workout"'
return statement(speech_text)
@ask.session_ended
def session_ended():

21
samples/reddit/test.py Normal file
View File

@ -0,0 +1,21 @@
import logging
import os
from flask import Flask
from flask_ask import Ask, request, session, question, statement
import random
import yaml
def read_exercises():
with open("workouts.yaml", 'r') as stream:
exercises = yaml.load(stream)
exercise_names = random.sample(list(exercises), 5)
workout_plan = []
for exercise_name in exercise_names:
exercise = str(exercises[exercise_name]["duration"][0]) + " " + str(exercises[exercise_name]["duration"][1] )+ " of " + exercise_name
workout_plan.append(exercise)
print(exercise)
read_exercises()

View File

@ -0,0 +1,55 @@
---
Run in place:
duration:
- 30
- seconds
explaination: "just run in place... dummy"
Jumping jacks:
duration:
- 30
- repetitions
explaination: "act like your Patric Star jumping of joy"
Burpees:
duration:
- 10
- repetitions
explaination: "do a push-up, then stand up and do a little jump"
Push-ups:
duration:
- 10
- repetitions
explaination: "lie on the ground, with your arms besides your toso. Angle them at 45° and push."
Mountain climbers:
duration:
- 20
- repetitions
explaination: "get in the upwards push-up position and move alternating knees to your chest"
Jump lunges:
duration:
- 15
- repetitions
explaination: "Walk in a way that your knees almost touch the ground"
Jump squats:
duration:
- 15
- repetitions
explaination: "jump and pull ypur knees to your chest"
Bicycle crunches:
duration:
- 20
- repetitions
explaination: "lay on your back with your hands behind your head, move your ellenbow to your opposite knee"
Squats:
duration:
- 15
- repetitions
explaination: "you know what a squat is, mind the 90°"