2010-06-29 28 views
1

我正在使用由類似於TellMe的引擎驅動的vxml。我將語音識別添加到語音郵件系統的電話提示中。新菜單將首先提示用戶輸入口頭信息,如果未找到匹配結果,或者未輸入任何信息,則會再次提示用戶使用按鍵音選項。vxml:我可以在語音提示和枚舉提示之間切換嗎?

原來的菜單看起來像這樣:

<menu id="msgedit"> 
     <prompt><enumerate><value expr="_prompt"/>press <value expr="_dtmf"/>.</enumerate></prompt> 
     <choice dtmf="9" next="#checkurgent">To deliver your message </choice> 
     <choice dtmf="7" next="#playmsg">To play your message </choice> 
     <choice dtmf="3" next="#rerecord">To discard your message and record over </choice> 
     <choice dtmf="2" next="#addtomsg">To add to your message </choice> 
     <choice dtmf="6" next="#testnumber">To enter a phone number where you may be reached </choice> 
     <choice dtmf="1" next="#cancel">To cancel making a message </choice> 
     <!-- handle no input/no match --> 
</menu> 

新的菜單如下:

<form id="msgedit"> 
     <field name="choice"> 
     <prompt> 
     <if count == 0"> 
      Please choose one of the following. 
      deliver, play back, rerecord, add to, 
      enter a callback number, or cancel. 
      <else/> 
      Please choose one of the following. 
      To deliver your message, press 9. 
      To play back your message, press 7. 
      To discard your message and rerecord, press 3. 
      To add to your message, press 2. 
      To enter a callback number, press 6. 
      To cancel your message, press 1. 
     </if> 
     </prompt> 
     </field> 
     <filled> 
     <if cond="choice == 'deliver' || choice == '9'"> 
      <goto next="#checkurgent"/> 
      <elseif cond="choice == 'play' || choice == '7'"/> 
      <goto next="#playmsg"/> 
      <elseif cond="choice == 'rerecord' || choice == '3'"/> 
      <goto next="#rerecord"/> 
      <elseif cond="choice == 'add' || choice == 'add to' || choice == '2'"/> 
      <goto next="#addtomsg"/> 
      <elseif cond="choice == 'enter callback number' || choice == 'callback number' || choice =='6'"/> 
      <goto next="#testnumber"/> 
      <elseif cond="choice == 'cancel' || choice =='1'"/> 
      <goto next="#cancel"/> 
      <else/> 
      <throw event="nomatch"/> 
     </if> 
     </filled> 
     <!-- handle no input/no match --> 
    </form> 

不過,我想用<enumerate><choice>行爲從原來的菜單改爲重新提示長文本(這太長並導致錯誤)。

問題:有沒有辦法在第二種提示類型中使用第一種提示樣式?我可以放在場內嗎?我該怎麼做?

回答

0

選擇元素特定於菜單。雖然可以在常規提示中使用枚舉,但在第一個示例中它使用的方式是將提示綁定到允許的輸入。對於某個字段,您將從定義的語法中獲得可用的輸入。

在後一點上,您的代碼段不會提及語法,也不會指定字段類型。語法是在VoiceXML文檔中的更高級別定義還是內置語法?如果不是,那可能是你錯誤的根源。

您可以使用菜單和選擇語音識別,但選擇與枚舉定義的方式:

這是從的VoiceXML 2.0規範的修改示例:

<menu> 
    <choice dtmf="1" next="http://www.sports.example.com/vxml/start.vxml"> 
    <grammar src="sports.grxml" type="application/srgs+xml"/> 
    Press 1 or say Sports for sports scores 
    </choice> 
    <choice dtmf="2" next="http://www.weather.example.com/intro.vxml"> 
    <grammar src="weather.grxml" type="application/srgs+xml"/> 
    Press 2 or say weather for weather 
    </choice> 
    <choice dtmf="3" next="http://www.stargazer.example.com/voice/astronews.vxml"> 
    <grammar src="astronews.grxml" type="application/srgs+xml"/> 
    press 3 or say Stargazer astrophysics for ? 
    </choice> 
</menu> 

如果你把提示輸入一個ECMAScript數組,你也可以使用枚舉。

一般來說,我會推薦現場方法。爲獲得豐富的提示和錯誤處理,您獲得更多靈活性。菜單/選項是一種適用於簡單,有限情況的快捷方式。

+0

所以我可以使用'

'來代替語音提示提示'
'?這很好知道。但這裏是我的問題:假設我需要能夠根據時間在兩個不同菜單之間切換,或者用戶沒有啓用語音記錄。在''我可以放入''來改變提示。我可以在''標籤中做到這一點嗎? – mtmurdock 2010-06-30 13:20:04

+0

根據VoiceXML DTD(http://www.w3.org/TR/voicexml20/vxml.dtd),選擇中允許的唯一元素是語法。因此,你不能在選擇元素中做到這一點。你可以在一個表格中。爲了獲得最佳用戶體驗,我建議爲每個路徑指定一個聲音片段,並使用音頻元素的srcexpr和您的標記來選擇正確的片段。 – 2010-06-30 17:25:17

+0

謝謝。我想出了一些與衆不同的東西,但是你把我放在了正確的軌道上。 :) – mtmurdock 2010-07-01 00:35:54