Author Topic: How do I...Create a Time-Sensitive Response?  (Read 3604 times)

Mike308

  • Newbie
  • *
  • Posts: 48
How do I...Create a Time-Sensitive Response?
« on: February 18, 2017, 05:48:16 PM »
The desired effect is for VA to select a response to a prompt based on the actual clock time. A simplified premise as follows:

"Good morning." (user prompt)

IF [Time] = 0600 to 0900 then TTS "Good morning"
IF [Time] = 0901 to 1200 then TTS "Getting a late start are we?"
If [Time] = 1201 to 1400 then TTS "You sober yet or just wanna try again tomorrow?"

You get the idea.... 

I can ask VA what time it is and get  the correct answer, so I know VA can access the clock. I just can't figure out how to get VA to make a selective decision comparing the "Time Now" against a set of parameters.

I went through Pfeil's code here  http://voiceattack.com/smf/index.php?topic=795.msg4036#msg4036  and see that he is doing calculations against Time, but my kung fu is weak. Guessing this sorta trick has been done before, can somebody point me to an example?  Many thanks.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: How do I...Create a Time-Sensitive Response?
« Reply #1 on: February 19, 2017, 01:07:40 AM »
You're pretty close to the answer already:
Code: [Select]
Begin Text Compare : [{EXP: {TIMEHOUR24}{TIMEMINUTE}  >= 0600 And {TIMEHOUR24}{TIMEMINUTE}  <= 0900}] Equals '1'
    Say, 'Good morning'
Else If Text Compare : [{EXP: {TIMEHOUR24}{TIMEMINUTE}  >= 0901 And {TIMEHOUR24}{TIMEMINUTE}  <= 1200}] Equals '1'
    Say, 'Getting a late start are we?'
Else If Text Compare : [{EXP: {TIMEHOUR24}{TIMEMINUTE}  >= 1201 And {TIMEHOUR24}{TIMEMINUTE}  <= 1400}] Equals '1'
    Say, 'You sober yet or just wanna try again tomorrow?'
End Condition

Mike308

  • Newbie
  • *
  • Posts: 48
Re: How do I...Create a Time-Sensitive Response?
« Reply #2 on: February 19, 2017, 08:34:58 PM »
Ah perfect - thank you so much!

RedMonster

  • Guest
Re: How do I...Create a Time-Sensitive Response?
« Reply #3 on: February 24, 2017, 07:42:43 AM »
You could also use just the {TIMEHOUR24} token to compare time of day. From there you could use a simple if() statement and parse out the time of day.

You can check out the CEDAR profile I've linked below to see a working example, just look through the code for the "greeting" command to see how the code actually works (on my macbook or I would give you the exact code)