View Single Post
Posts: 137 | Thanked: 150 times | Joined on Jan 2010
#83
I've gone through config.xml for the nokia speech and I think this is how it works.
This does not describe the text section as it is not interesting for speech.

How to evaluate:

1. Get the next element
2. If it is a link element define a function and don't evaluate it
3. If the element has an action then perform it
4. Evaluate any tests associated with it. If the result is true:
a. descend into the child elements
b. start from step 1 with the child elements
c. return true (ignoring result of child elements - except for links)
5. Else go to step 1

The evaluation of elements is basically like:
{
if (element1) return true;
if (element2) return true;
if (element3) return true;
return false;
}



Elements

link: defines a function which evaluates its children and returns true if one of them return true else false. id attribute is the name of the function
ref: calls a function defined by a link element. If the function result is true then evaluate the child elements and then return true
dummy: evaluates the child elements, but returns false. This allows us to test two independent conditions.
soundfile: plays the sound specified in the val attribute. returns false
state: tests if the state object contains the value in the val attribute. logic attribute modifieds the check somehow?. logic values of 1 and 2 are used. If true evaluates children then returns true else returns false
flags: tests if the flags object contains the value in the val attribute. If true evaluates children then returns true else returns false
distancetomaneuver: tests the distance to the current maneuver. min and max can be tested. Distance is in meters?? If true evaluates children then returns true else returns false
maneuver: tests if the current maneuver type is the one specified in the val attribute. Seems to be related to Maneuver._action
turn: tests if the current maneuver turn is the one specified in the val attribute. Seems to be related to Maneuver._turn
nextmaneuver: tests if the next (the one after the current maneuver) maneuver type is the one specified in the val attribute. This is used for chaining message like "turn left *and then* turn right"
nextturn: tests if the next (the one after the current maneuver) maneuver turn is the one specified in the val attribute.
setstate: sets the state contained in setflagp or clears it if setflagn is used. Values such as MANEUVER_ANNOUNCE are used but never seem to be used in tests, se they are for the benefit of something external to the script. I think this state might be a single value state that is not related to the state object used by the "state element"
setflags: sets the flag contained in setflagp or clears it if setflagn is used.
distanceposition: tests the distance to the maneuver and from the previous maneuver. minto and maxto refer to the current maneuver and minfrom and maxfrom the maneuver that we just passed.testflagn and setflagp seem to check bits set in a numeric state flag (separate from that used by the setstate and state elements). If any of the bits passed to testflagn are set then the test fails. setflagp ORs the bits with the current flags.
timeposition: same as distanceposition but using a time calculation. I'm not sure what the units are. (it could be tricky to get a reasonably accuarate time estimate)


The flags used by distanceposition and timeposition seem to support 4 types of voice commands:
Announce maneuver (MANEUVER_ANNOUNCE) if 1100 clear set bit 0010 -> reminder 2 (MANEUVER_ALL) if 1100 clear set bit 1000 -> reminder 1 (MANEUVER_ALL) if 0100 clear set bit 0100 -> command (MANEUVER_COMMAND) if 0001 clear set 1111


The main "entry point" when evaluating is the check that we have the WITH_ROUTE state. Then it checks that we are on target and don't have invalid junctions. Then it checks for various distance and times to maneuvers and decides what, if anything, to say. I guess that this should be evaluated on every position update.
 

The Following 9 Users Say Thank You to CormacB For This Useful Post: