diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-07-26 23:31:25 +0000 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-07-26 23:31:25 +0000 |
| commit | 78389f252a021d642a7a0146b658f0465da6e264 (patch) | |
| tree | b740c6339ceba381004d3441f2459f65d38d02a6 /client/modules/Time.py | |
| parent | 2c55f4da462383ee6c7b89ea44e5c40cd5badf0c (diff) | |
| download | jasper-client-78389f252a021d642a7a0146b658f0465da6e264.tar.gz jasper-client-78389f252a021d642a7a0146b658f0465da6e264.zip | |
Work on Google STT on RPi.
Diffstat (limited to 'client/modules/Time.py')
| -rw-r--r-- | client/modules/Time.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/client/modules/Time.py b/client/modules/Time.py new file mode 100644 index 0000000..2fe8a10 --- /dev/null +++ b/client/modules/Time.py @@ -0,0 +1,33 @@ +import datetime +import re +from app_utils import getTimezone +from semantic.dates import DateService + +WORDS = ["TIME"] + + +def handle(text, mic, profile): + """ + Reports the current time based on the user's timezone. + + Arguments: + text -- user-input, typically transcribed speech + mic -- used to interact with the user (for both input and output) + profile -- contains information related to the user (e.g., phone number) + """ + + tz = getTimezone(profile) + now = datetime.datetime.now(tz=tz) + service = DateService() + response = service.convertTime(now) + mic.say("It is %s right now." % response) + + +def isValid(text): + """ + Returns True if input is related to the time. + + Arguments: + text -- user-input, typically transcribed speech + """ + return bool(re.search(r'\btime\b', text, re.IGNORECASE)) |
