Author Topic: GgCal Quick Add -- overcoming idiosyncrasies of Google *and* Microsoft!  (Read 2316 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
The Google Calendar API provides this theoretically handy "Quick Add" feature, which is supposed to allow us to quickly add events to our Google Calendar feed(s).

"Meeting with John tomorrow at 3 pm". "Breakfasts with Grandma at 9 am every Sunday." In VC, we have the corresponding GgCal.QuickAdd action. Great, right?

Alas. Both Google and Microsoft make our lives complicated. For example, try the breakfast with Grandma line and Google will interpret "at 9 am" as your *location* not the time. ... We can't do much about that -- you just have to learn how to speak Googlese. "Breakfasts with Grandma every Sunday at 9 am" works properly (??).

Google also requires that times be specified as digits (though you can say "noon" or "midnight"). Since I wanted to have fairly broad flexibility in the way that I phrase my Quick Add requests, I wanted to use a Dictation payload for my command. The problem is that the SAPI engine translates dictated numbers into word form, rather than as digits. "Dinner tonight at nine". Google no likey.

So, I have adapted one of our existing Python scripts specifically for this purpose.  It is working quite well for me, using the following voice command:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.2-->
<commandGroup open="True" name="GcCal quick add" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="466" name="GgCal quick add" enabled="true" alwaysOn="False" confirm="True" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>result=time2int('{1}')</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Adding {LastResult} to Google Calendar.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Adding "{LastResult}" to Google Calendar.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>GgCal.QuickAdd</cmdType>
      <params>
        <param>{LastResult}</param>
        <param>VoxCommando Alerts</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Google add</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
    <phrase optional="true">to my agenda, to my calendar</phrase>
  </command>
  <command id="467" name="load PY script on VC launch" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <params>
        <param>PY\time2int.py</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
</commandGroup>

The required Python script, time2int.py, is attached. LIMITATION: This expects a 12-hour clock. You'll need to modify the script if you want to use a 24-hour clock.

In the command, you can specify a particular calendar feed as I did (VoxCommando Alerts), or delete it entirely to use your default feed.

(And apologies to actual coders -- it's a very amateur script that you will shake your head at. I don't code for reals. ;))
« Last Edit: August 03, 2016, 01:21:48 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: GgCal Quick Add -- overcoming idiosyncrasies of Google *and* Microsoft!
« Reply #1 on: August 03, 2016, 01:23:12 PM »
I just noticed that my Python script was translating strings like "The time is one forty five" as "The time is 145", rather than "The time is 1:45".

I've updated the first post in this thread with a new version of the Python code. Sorry about that.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)