<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0" application="../../root.xml">
<!--
NOTE: This page requires server-side processing.  It has been written to run
on a java application server (JSP).  If you need to run this file on a different
platform (ASP, PHP, etc) you will need to change the code used to retrieve
and write the posted variables.

If you need to change this file's extension so it will run on a different
platform, you will also need to update the value for
'disambiguateFilename'. That value is set in '/root.xml'
-->
<%

String promptContent = request.getParameter("promptContent");
String grammarContent = request.getParameter("grammarContent");

%>
<property name="universals" value="help"/>

<var name="RejectionCount" expr="0"/>

<form>
    
    <var name="streetNameSpoken" />
    
    <field name="streetName">
    
        <%=promptContent%>
        <grammar> [
            <%=grammarContent%>
        ] </grammar>

        <catch event="giveUp">
            <prompt>
                <audio expr="application.audioDirURI + '/DisambiguationFailurePt1.wav'">
                        I still can't get it. We'll continue on using
                </audio>

                <value expr="streetNameSpoken" />

                <audio expr="application.audioDirURI + '/DisambiguationFailurePt2.wav'">
                        as your street name.
                </audio>
            </prompt>
            <var name="status" expr="false"/>
            <return namelist="status"/>            
        </catch>

        <nomatch>
            <if cond="RejectionCount >= application.maxRejections">
                <throw event="giveUp"/>
            <else/>
                <audio expr="application.audioDirURI + '/NoMatch.wav'">
                    I didn't catch that.
                </audio>
                <assign name="RejectionCount" expr="RejectionCount + 1"/>
                <throw event="help"/>
            </if>
        </nomatch>

        <noinput>
            <if cond="RejectionCount >= application.maxRejections">
                <throw event="giveUp"/>
            <else/>
                <audio expr="application.audioDirURI + '/NoInput.wav'">
                    I didn't hear your response.
                </audio>
                <assign name="RejectionCount" expr="RejectionCount + 1"/>
                <throw event="help"/>
            </if>
        </noinput>

        <help>
            <audio expr="application.audioDirURI + '/DisambiguationHelp.wav'">
                    I'm trying to determine which particular street you live on.
                    Please listen to the choices and repeat back the correct one.
            </audio>
            <reprompt/>
        </help>
        
        <filled>
            <var name="status" expr="true"/>
            <var name="CASSformat" expr="streetName.streetNameCASS"/>
            <var name="spoken" expr="streetName.spoken"/>
            <return namelist="status spoken CASSformat"/>
        </filled>
    </field>
            
</form>

</vxml>