Author Topic: more human style time telling (with world time)  (Read 3000 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
more human style time telling (with world time)
« on: September 19, 2014, 10:53:09 PM »
this is a total rewrite of the original command ... (the original is posted below)

it answers the time in 2 methods
the first if statement controls the probability of using method 1 or 2 (set to 70%) ...

method 1 uses straight forward {DtCustom.h:mm}.

method 2 uses formal English syntax of saying the time (like it is quarter past ten) ... as well it approximate the minutes to multiplication of 5.  ie. 10:13 will be said as it is quarter past 10 ...
for the second method a python script (attached) that defines new function is needed ... so it should be loaded with vc.loaded

now it supports world time ... must run the command that built the xml ... (an advanced py user, can avoid using the internet, and use py time function ... but that is beyond my knowledge and time for the moment)

more it adds various part of the sentence to create subtle variety of answers .... 

always this can be combined with nime5ter post (http://voxcommando.com/forum/index.php?topic=1370.msg11765#msg11765) to give it even more personlised feel.


if you find bugs ... let me know and will squash them  ...

feedback is appreciated, specially if you find new varieties to report the time

« Last Edit: August 20, 2015, 08:07:25 PM by Haddood »
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: more human style time telling
« Reply #1 on: September 20, 2014, 10:16:31 PM »
Nice command.  I like it.

For your default time you can just use this format: {DtCustom.h:mm}

It's shorter, but also it gets rid of the superfluous "oh" at the beginning.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: more human style time telling
« Reply #2 on: August 20, 2015, 07:54:32 PM »
this is just to keep record of the original command

here is an xml that give some variation in telling the time ...

 the first if statement controls the probability of using method 1 or 2 (set to 50%) ...

method 1 uses straight forward {DtCustom.hh}:{DtCustom.mm} {DtCustom.h:mm} (see James post below}. I did not use {ShortTime} because it adds am or pm (not sure if it can report time in 24h format which we do not want as well)

method 2 uses formal English syntax of saying the time (like it is quarter past ten) ... as well it approximate the minutes to multiplication of 5.  ie. 10:13 will be said as it is quarter past 10 ...
for the second method a python script (attached) that defines new function is needed ... so it should be loaded with vc.loaded

this can be combined with nime5ter post (http://voxcommando.com/forum/index.php?topic=1370.msg11765#msg11765) to give it even more personlised feel.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.1.0-->
<command id="274" name="Time" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>{Rnd.1.4}&amp;&amp;3</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>{DtCustom.h:mm}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.StopMacro</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>VcAdvanced.Log</cmdType>
        <params>
          <param> --------- Performing human time</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>result = conditions ({DtCustom.mm}, 3, 57, 5)</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>0&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>it is {DtCustom.h } o'clock</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.StopMacro</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>12&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>it is {DtCustom.h } o'clock</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.StopMacro</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>1 | 11&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>five</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>2 | 10&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>ten</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>3 | 9&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>quarter</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>4 | 8&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>twenty</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>5 | 7&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>twenty five</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>6&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>half</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>{DtCustom.mm}&amp;&amp;33</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>it is {LastResult} past {DtCustom.h }</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>mnt</param>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>result = int ({DtCustom.h })+1</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>it is {var.mnt} to {LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <event>Time.Tell</event>
  <phrase>What Time is it, What Time it is, have you got the time</phrase>
  <phrase optional="true">?</phrase>
</command>
When Voice command gets tough, use hand gestures