Export (0) Print
Expand All

mark

Sets a bookmark allowing you to determine when the user barged in on a prompt.

<mark 
name = "string"
nameexpr = "ECMAScript_Expression"
/>

name

The name of the mark.

nameexpr

An ECMAScript expression that evaulates to the name of the mark at run-time.

If a mark is executed and a non-link recognition occurs, the following shadow variables are exposed on the active field:

name$.markvalid

DEPRECATED. Indicates whether or not a mark was active when the user barged in.

name$.markname

The name of the last mark that was executed before barge-in or the end of playback occurred. If no mark was active, this shadow variable is undefined.

name$.marktime

The number of milliseconds that elapsed since the last mark was executed when barge-in or the end of audio playback occurred. If no mark was active, this shadow variable is undefined.

The name and nameexpr attributes are mutually exclusive.

The shadow variables are only set on the active field when a mark was executed and a valid recognition occurred.

The shadow variables are not set when a nomatch or a noinput occurs.

The shadow variables are not set when a link is matched.

Prior to Revision 3, the shadow variables are not set on application.lastresult$. In Revision 3 and later, the shadow variables are set on application.lastresult$ if a valid recognition or a nomatch occurs.

In Revision 3 and later, there are numerous differences from prior revisions in the handling of the mark element and its shadow variables:

  1. Prior to Revision 3, if no mark was executed, the markname shadow variable was set to the string "undefined". In Revision 3 and later, it is set to ECMAScript undefined.

  2. Prior to Revision 3, if no mark was executed, the marktime shadow variable was set to 0. In Revision 3 and later, it is set to ECMAScript undefined.

  3. In Revision 3 and later, the markvalid shadow variable is deprecated, and the recommended way to determine if a mark was executed is to check that markname or marktime is not undefined. Prior to Revision 3, markvalid is a string, while in Revision 3 and later, it is a boolean.

  4. Prior to Revision 3, when a nameexpr attribute of the mark element cannot be evaluated, the interpreter throws a generic error event. In Revision 3 and later, the interpreter throws error.semantic.

  5. Prior to Revision 3, when a mark element is executed, the mark-related properties are never set on application.lastresult$. In Revision 3 and later, if a mark element has been executed and a recognition occurs, the markname and marktime properties of application.lastresult$ are set.

  6. Prior to Revision 3, when a nomatch occurs, if a mark has been executed, the mark information is available via the markname and marktime shadow variables of the active input item. In Revision 3 and later, the mark information is available exclusively via the markname and marktime properties of application.lastresult$.

  7. Prior to Revision 3, if an input item is filled, a mark is executed, and the prompts are flushed as a result of encountering a fetchaudio, then the input item's markname and marktime shadow variables are modified. In Revision 3, they are not modified in that situation.

The following example declares two mark elements interpersed among three audio clips. If the user barges in during playback of the first clip, the markname shadow variable is undefined. If the user barges in during playback of the second clip, markname is set to "mark1". If the user barges in during the third clip or before the timeout elapses, markname is set to "mark2".

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
<form id="main">

<link event="onstop">
   
   <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
      <rule id="root_rule" scope="public">
         <one-of>
            <item>
               stop
            </item>
         </one-of>
      </rule>

   </grammar>

</link>

<catch event="onstop">
   <exit/>
</catch>

<field name="todo">
   <prompt>
      Fourth ranked Oklahoma defeated Kansas 64 to 55.
      <mark name="mark1"/>
      Duke demolished North Carolina State 91 to 61.
      <mark name="mark2"/>
      Central Michigan was downed by Toledo 62 to 54.
   </prompt>
   
   
   <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
      <rule id="root_rule" scope="public">
         <item>
            <one-of>
               <item>
                  tell
                  me
                  more
               </item>
               <item>
                  tell_me_more
               </item>
               <item>
                  tell_me
                  more
               </item>
            </one-of>
            <tag>out.todo = "more";</tag>
         </item>
      </rule>

   </grammar>

   
   <noinput>
      <exit/>
   </noinput>
 
   <nomatch>
     <if cond="typeof(application.lastresult$.markname) != undefined">
       <log>bargein occurred 
         <value expr="application.lastresult$.marktime"/> ms 
         after '<value expr="application.lastresult$.markname"/>'.</log>
     <else/>
       <log>bargein occurred before first mark.</log> 
     </if>
   </nomatch>
   
   <filled>
      <if cond="typeof(todo$.markname) != 'undefined'">
         <log>bargein occurred <value expr="todo$.marktime"/> ms 
             after '<value expr="todo$.markname"/>'.</log>
      <else/>
         <log>bargein occurred before first mark.</log> 
      </if>
   </filled>

</field>
</form>
</vxml>

The following example demonstrates how you might validate billing a third party for playing their advertisements. The following code plays an advertisement prior to asking the user to say the name of a baseball team. The customer is only obligated to pay you if at least five seconds of the advertisement are played.

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">

<link event="event.onquit">


<grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">


<rule id="root_rule" scope="public">



<one-of>




<item>





quit




</item>



</one-of>


</rule>


</grammar>

</link>

<catch event="event.onquit">
   <exit/>
</catch>

<script>
<![CDATA[
   var aTeams = ["red sox", "rangers", "yankees", "mariners"];
   
   // generate a random report for the specified team
   function GetReport(aTeams, team)
   {
      var opp = PickOpponent(aTeams, team);
      var bWin = Math.floor(Math.random()*100) % 2;
      var oScores = GetScores();
      
      return "The " + team + (bWin ? " beat " : " lost to ") + 
          "the " + opp + " " + (bWin ? oScores.win : oScores.lose) + 
          " to " + (bWin ? oScores.lose : oScores.win) + ".";
   }
   
   // pick a random opponent
   function PickOpponent(aTeams, sTeam)
   {
      while(1) {
         var opp = aTeams[Math.floor(Math.random()*aTeams.length)];
         if (opp != sTeam) {
            return opp;
         }      
      }   
   }
   
   // generate a couple of scores
   function GetScores()
   {
      var i = 0, j = 0;
      while (i == j) {
         i = GetScore();
         j = GetScore();
      }
   
      if (i < j) {
         return {'win' : j, 'lose' : i};
      } else {
         return {'win' : i, 'lose' : j};
      }   
   }   
   
   // generate a random score from 1 to 20
   function GetScore()
   {
      return Math.floor(Math.random()*20) +1;
   }
]]>
</script>

<var name="bPlayedAd" expr="false"/>

<form id="bb_scores">
<field name="team">
   <property name="inputmodes" value="voice"/>
   <property name="timeout" value="0s"/>

   <prompt cond="!bPlayedAd">
      <mark name="ad_start"/>
      Baseball scores brought to you by Elephant Peanuts.
      There's nothing like the taste of fresh roasted peanuts.
      With a bag of Elephant Peanuts, it doesn't matter 
      if you're watching the game from the first base line
      or in your living room.  
      Elephant Peanuts. Ask for them by name.
      <mark name="ad_end"/>
      <break time="500ms"/>
      Say the name of a team. For example, say Boston Red Sox.
      <audio src="http://naturalsound.svc.tellme.com/common-audio/intellipause.wav"/> 
   </prompt>

   <prompt cond="bPlayedAd">
     Say a team name. For example, say Seattle Mariners.
     When your done here, say quit.
     <audio src="http://naturalsound.svc.tellme.com/common-audio/intellipause.wav"/> 
   </prompt>

   
   <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
      <rule id="root_rule" scope="public">
         <one-of>
            <item>
               <one-of>
                  <item>
                     texas
                  </item>
                  <item>
                     rangers
                  </item>
                  <item>
                     texas
                     rangers
                  </item>
               </one-of>
               <tag>out.team = "rangers";</tag>
            </item>
            <item>
               <one-of>
                  <item>
                     boston
                  </item>
                  <item>
                     red_sox
                  </item>
                  <item>
                     boston
                     red_sox
                  </item>
               </one-of>
               <tag>out.team = "red sox";</tag>
            </item>
            <item>
               <one-of>
                  <item>
                     seattle
                  </item>
                  <item>
                     mariners
                  </item>
                  <item>
                     seattle
                     mariners
                  </item>
               </one-of>
               <tag>out.team = "mariners";</tag>
            </item>
            <item>
               <one-of>
                  <item>
                     new_york
                  </item>
                  <item>
                     yankees
                  </item>
                  <item>
                     new_york
                     yankees
                  </item>
               </one-of>
               <tag>out.team = "yankees";</tag>
            </item>
         </one-of>
      </rule>

   </grammar>


   <noinput count="1">
      <log>bill=true (noinput)</log>
      <assign name="bPlayedAd" expr="true"/>
       Sorry. I couldn't hear you.
       <reprompt/>
   </noinput>

   <noinput count="2">
      Sorry. I still couldn't hear you.
      <reprompt/>
   </noinput>

   <nomatch count="1">
      <log>bill=false (nomatch)</log>
      <assign name="bPlayedAd" expr="true"/>
      Sorry. I didn't get that.
      <reprompt/>
   </nomatch>

   <nomatch count="2">
      Sorry. I still didn't get that.
      <reprompt/>
   </nomatch>

   <filled>
      <assign name="bPlayedAd" expr="true"/>
      <log><value expr="team$.toSource()"/></log>
      <if cond="typeof(team$.markname) != 'undefined' &amp;&amp; 
         (team$.markname=='ad_end' || 
         (team$.markname=='ad_start' &amp;&amp; 
            team$.marktime &gt;= 5000))">
      <log>bill=true (mark)</log>
      <else/>
          <log>bill=false (mark)</log>
      </if>
   </filled>
</field>

<field name="play_score">
   <property name="timeout" value="0s"/>
   <property name="bargeintype" value="hotword"/>
   
   <prompt>
   <value expr="GetReport(aTeams, team)"/>
   </prompt>
   
   
   <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
      <rule id="root_rule" scope="public">
         <one-of>
            <item>
               stop
            </item>
            <item>
               cancel
            </item>
         </one-of>
      </rule>

   </grammar>

   
   <catch event="noinput nomatch">
       <goto next="#bb_scores"/>
   </catch>
   
   <filled>
       <goto next="#bb_scores"/>
   </filled>
</field>

</form>
</vxml>

Community Additions

ADD
Show:
© 2014 Microsoft