Last active
August 25, 2017 21:32
-
-
Save 64lines/1117fe7d898bb592677a6ff17bd87d32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import random | |
| from datetime import datetime as date | |
| def get_voice(): | |
| # "Samantha" | |
| return "Tessa" | |
| def run_voice_command(text, voice): | |
| return os.system("say \"%s\" --voice=%s" % (text.encode('utf-8'), voice)) | |
| def get_hour(): | |
| return date.now().hour | |
| def is_morning(): | |
| return get_hour() < 12 | |
| def is_afternoon(): | |
| return 12 <= get_hour() < 18 | |
| def calculate_gretting_text(): | |
| return "Good morning" if is_morning() else "Good afternoon" if is_afternoon() else "Good evening" | |
| def greeting(): | |
| return run_voice_command(calculate_gretting_text(), get_voice()) | |
| def say_text(text): | |
| return run_voice_command(text, get_voice()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment