Condividi tramite


RunSpeech Example

  Microsoft Speech Technologies Homepage

The following example demonstrates how the RunSpeech algorithm activates the controls on a page.

<form id="Form1" method="post" runat="server">
  <speech:AnswerCall id="AC1" runat="server"></speech:AnswerCall>
      
  <speech:QA id="QA_HI" runat="server"  PlayOnce="True">
    <Prompt InlinePrompt="hello"></Prompt>
  </speech:QA>

  <speech:CompareValidator id="CompareValidator1" runat="server" 
    SemanticItemToValidate="SemanticItem1" ValueToCompare="seven"
    ValidationEvent="onchanged" >
    <Prompt InlinePrompt="you must say the word seven"></Prompt>
  </speech:CompareValidator>

  <speech:QA id="QA1" runat="server" >
    <Answers>
      <speech:Answer  ID="Answer1"
        SemanticItem="SemanticItem1" XPathTrigger="/Rule1">
      </speech:Answer>
    </Answers>
    <Reco >
      <Grammars>
        <speech:Grammar Src="NumberGrammar.grxml"></speech:Grammar>
      </Grammars>
    </Reco>
    <Prompt InlinePrompt="please say the word seven"></Prompt>
  </speech:QA>

  <asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>

  <speech:SemanticMap id="SemanticMap1" runat="server">
    <speech:SemanticItem id="SemanticItem1" runat="server" 
      TargetElement="TextBox1" TargetAttribute="value">
    </speech:SemanticItem>
  </speech:SemanticMap>

</form>

First iteration

RunSpeech evaluates the controls on the page as follows:

Control Activation Status
AC1 Can be activated. The completion flag for the control is False.
QA_HI Not evaluated.
CV1 Not evaluated.
QA1 Not evaluated.

RunSpeech activates the AC1 control. The control waits until it has an active call, then sets its completion flag to True and returns control to RunSpeech.

Second iteration

RunSpeech evaluates the controls on the page as follows:

Control Activation Status
AC1 Cannot be activated. The completion flag for the control is True.
QA_HI Can be activated. The internal activation count for the control is 0.
CV1 Not evaluated.
QA1 Not evaluated.

RunSpeech activates the QA_HI control and sets its internal activation count to 1. The control plays its prompt and returns control to RunSpeech.

Third iteration

RunSpeech evaluates the controls on the page as follows:

Control Activation Status
AC1 Cannot be activated, for the same reason as in the previous iteration.
QA_HI Cannot be activated. The internal activation count for the control is 1 and its PlayOnce property is True.
CV1 Cannot be activated. The validation state for the control is VALID.
QA1 Can be activated. The internal activation count for the control is 0.

RunSpeech activates the QA1 control, and sets its activation count to 1. The control plays a prompt asking the user to say the word "seven." Assume, for the purpose of demonstration, that the user says eight. The control places the word "eight" in SemanticItem1. Changing the value of SemanticItem1 causes the CV1 validator to examine SemanticItem1. Because the validator determines that the data is invalid, it sets the semantic state of SemanticItem1 to EMPTY, and it sets its own internal state to INVALID. After validation has been performed, QA1 returns control to RunSpeech.

Fourth iteration

RunSpeech evaluates the controls on the page as follows:

Control Activation Status
AC1 Cannot be activated, for the same reason as in the previous iteration.
QA_HI Cannot be activated, for the same reason as the previous iteration.
CV1 Can be activated. The internal state for the control is INVALID.
QA1 Not evaluated.

RunSpeech activates the CV1 validator to play its error message prompt. The validator sets its internal state to VALID and returns control to RunSpeech.

Fifth iteration

RunSpeech evaluates the controls on the page as follows:

Control Activation Status
AC1 Cannot be activated, for the same reason as in the previous iteration.
QA_HI Cannot be activated, for the same reason as the previous iteration.
CV1 Cannot be activated. The internal state for the control is VALID.
QA1 Can be activated. The control is authored to collect the word "seven" and place it in SemanticItem1, and SemanticItem1 is EMPTY. This setting indicates that the control has work to do.

RunSpeech activates the QA1 control, and it plays a prompt asking the user to say the word "seven." This time, the user says seven. The control places the word "seven" in SemanticItem1. Changing the value of SemanticItem1 causes the CV1 validator to examine SemanticItem1. The validator determines that the data is valid, and it sets its own internal state to VALID. After validation has been performed, QA1 returns control to RunSpeech.

Sixth iteration

RunSpeech evaluates the controls on the page as follows:

Control Activation Status
AC1 Cannot be activated, for the same reason as in the previous iteration.
QA_HI Cannot be activated, for the same reason as in the previous iteration.
CV1 Cannot be activated. Its internal state is VALID.
QA1 Cannot be activated. Its target data in SemanticItem1 is no longer EMPTY.

RunSpeech submits the page, because every control on the page has completed its task.