-- 作者:ripoff
-- 发布时间:7/30/2008 11:40:00 AM
-- 如何编写grxml
我想输入4个字符,然后以#号结束。 grxml文件如下: <?xml version="1.0"?> <!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd"> <grammar mode="dtmf" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd" xmlns="http://www.w3.org/2001/06/grammar"> <rule id="root"> <one-of> <item> 0 </item> <item> 1 </item> <item> 2 </item> <item> 3 </item> <item> 4 </item> <item> 5 </item> <item> 6 </item> <item> 7 </item> <item> 8 </item> <item> 9 </item> </one-of> </rule> <rule id="pin" scope="public"> <one-of> <item> <item repeat="4"><ruleref uri="#digit"/></item> # </item> <item> * 9 </item> </one-of> </rule> </grammar> vxml文件如下: <?xml version="1.0" ?> <!DOCTYPE vxml PUBLIC "-//W3C//DTD VOICEXML 2.1//EN" "http://www.w3.org/TR/voicexml21/vxml.dtd"> <vxml version="2.1" xmlns:xsi="http://www/w3/org/2001/vxml"> <form> <!-- If nothing else is specified, the first <form> that is encountered is used as initial dialog --> <field name="ticket_num"> <prompt> Read the 4 digit number from your ticket. </prompt> <help>The 4 digit number is to the lower left.</help> <grammar src="dtmf.grxml" type="application/srgs+xml"/> <filled> <if cond="ticket_num.length != 4"> <prompt> Sorry, I didn't hear exactly 4 digits. </prompt> <assign name="ticket_num" expr="undefined"/> <else/> <prompt> I heard <say-as interpret-as="vxml:digits"> value expr="ticket_num"/></say-as> </prompt> </if> </filled> </field> </form> </vxml> 我用的是openvxi来跑vxml的,如果输入一个字符串,就会返回no match,只能 一个个字符输入,但是输入一个字符的又不会去match,这个怎么处理呢?
|