Share via


RunSpeech - Example

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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

<form id="Form1" method="post" >
    <speech:AnswerCall id="AC1" ></speech:AnswerCall>
    <speech:QA id="QA_HI"   PlayOnce="True">
        <Prompt InlinePrompt="hello"></Prompt>
    </speech:QA>
    <speech:CompareValidator id="CompareValidator1"  
        SemanticItemToValidate="SemanticItem1" ValueToCompare="seven"
        ValidationEvent="onchanged" >
        <Prompt InlinePrompt="you must say the word seven"></Prompt>
    </speech:CompareValidator>
    <speech:QA id="QA1"  >
        <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" >
    <speech:SemanticItem id="SemanticItem1"  
        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 and 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 zero.

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 zero.

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 sets its own internal state to INVALID. After validation is 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 in 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 in 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 is not complete.

RunSpeech activates the QA1 control and plays a prompt asking the user to say "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 sets its own internal state to VALID. After validation is 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.

See Also

Other Resources

SpeechControls Scripting