5

我正在嘗試創建一個亞馬遜Alexa技能工具包來完成一些自動化操作,這需要採用由字符串和數字組成的語音輸入(a-test12fish)。如何給亞馬遜Alexa技能套件(ASK)混合字符串輸入數字?

當我使用自定義的插槽在Alexa的技能套裝,它沒有讓我在與數字的字符串鍵。當我嘗試在ask alexa, dangerZone find a-test12fish到鍵,我發現了以下錯誤:

Error: Invalid text input. Text should begin with alphabets and should only contain alphabets, whitespaces, periods or apostrophes

我如何克服這個問題?

+0

你好Sathish,你覺得這一個呢? – Kal

回答

0

你沒有說明你是如何讓用戶說出價值的。例如,「衝刺測試十二條魚」或「衝刺測試一條兩條魚」。在任何情況下,識別系統的設計都是爲了識別單詞,而且數據不是一個有效的單詞。

作爲解決這個問題,你可以嘗試建立與所有有效字符值和樣本創建一個自定義插槽類型拼寫溶液(後者輸入)言論的支持下,有效長度。

你將有一些工作,重組消息,但它不應該是太複雜了。可能的挑戰仍將來自識別器。雖然我沒有在Alexa下面測試過這個場景,但我用過的大多數字符串都是變長字符串。聲音太相似了,有幾個值很容易被誤認爲暫停和背景噪音。典型的解決方法是使用phonetic alphabet

+0

謝謝你的輸入,我想說它是「連字符測試一個兩條魚」,意思是說,雖然我嘗試使用建議的拼音字母 – Sathish

0

一個不同的方法將在系統的限制內發揮作用。你可以用不同的名稱來引用它。

以提示用戶「說,1對,test12fish」等等。並在內部將其映射到您的特定值。

-3

使用SSML,其中u可以設計自己的pronunciation.Please檢查的風格。

2

這是一個解決方案。

你可能不希望在意向架構來完成這一點。相反,嘗試使用Node.js創建自定義模式,將字母,數字和符號編譯爲單個響應。這是我對字母數字輸入模式的再現。請注意:我只是爲了迴應你的問題而寫這篇文章,並沒有用更大的技巧來測試它。有了這個說法,我已經與MODES取得了巨大的成功,並且當我有機會的時候,我一定會以自己的技術實現這一點。

此代碼背後的想法是,您將用戶推入獨立模式,忽略除NumberIntentLetterIntent,SymbolIntent以及一些幫助功能之外的所有意圖。用戶快速輸入他們的字母數字值,並在完成後激活CompletedIntent。這個字母數字值可以在你的技能的其他地方使用。如果您還沒有使用Modes請注意,在完成或退出後,您將被重定向回LOBBYMODE,您可以在其中繼續訪問您的技能中的其他意圖。

var lobbyHandlers = Alexa.CreateStateHandler(states.LOBBYMODE, { 

    'enterPasswordIntent': function() { 
     this.attributes['BUILDPASSWORD'] = ''; 
     this.handler.state = states.PASSWORDMODE; 
     message = ` You will now create a password one letter, number or symbol at a time. there will be no message after each entry. simply wait for alexa's ring to become solid blue then stay your next value. When you are satisfied say complete. Begin now by saying a number, letter, or keyboard symbol. `; 
     reprompt = `Please say a number letter or symbol`; 
     this.emit(':ask', message, reprompt); 
    }, 

    //Place other useful intents for your Skill here 

    'Unhandled': function() { 
     console.log("UNHANDLED"); 
     var reprompt = ` You're kind of in the middle of something. Say exit to end createing this password. otherwise say complete if you've stated the whole password. or repeat to hear the current password you've entered. `; 
     this.emit(':ask', reprompt, reprompt); 
    } 
}); 


var buildAlphaNumericPasswordHandlers = Alexa.CreateStateHandler(states.PASSWORDMODE, { 
    'numberIntent': function() {// Sample Utterance: ninty nine AMAZON.NUMBER 
     var number = this.event.request.intent.slots.number.value; //I believe this returns a string of digits ex: '999' 
     this.attributes['BUILDPASSWORD'] = this.attributes['BUILDPASSWORD'].concat(number); 
     message = ``; //No message to make saying the next letter, number or symbol as fluid as possible. 
     reprompt = `Please say the next number letter or symbol`; 
     this.emit(':ask', message, reprompt); 
    }, 
    'letterIntent': function() {// Sample Utterance: A -- Custom Slot LETTERS [A, b, c, d, e, ... ] 
     var letter = this.event.request.intent.slots.letter.value; 
     this.attributes['BUILDPASSWORD'] = this.attributes['BUILDPASSWORD'].concat(letter); 
     message = ``; //No message to make saying the next letter, number or symbol as fluid as possible. 
     reprompt = `Please say the next number letter or symbol`; 
     this.emit(':ask', message, reprompt); 
    }, 
    'symbolIntent': function() {// Sample Utterance: Dash -- Custom Slot SYMBOLS [Pound, Dash, Dollar Sign, At, Exclamation point... ] 
     var symbol = this.event.request.intent.slots.symbol.value; 

     // Create a dictionary object to map words to symbols ex Dollar Sign => $. Will need this because you likely cant put $ as a custom slot value. Can also map multiple names to the same value ex. Dash => Tack = \> "-" 
     var singleCharacterSymbol = symbolDict[symbol]; //^^^ Need to create dictionary 

     this.attributes['BUILDPASSWORD'] = this.attributes['BUILDPASSWORD'].concat(singleCharacterSymbol); 
     message = ``; //No message to make saying the next letter, number or symbol as fluid as possible. 
     reprompt = `Please say the next number letter or symbol`; 
     this.emit(':ask', message, reprompt); 
    }, 
    'CompleteIntent': function() { //Sample Utterance: Complete 
     console.log("COMPLETE"); 
     this.handler.state = states.LOBBYMODE; 
     var reprompt = ` Your entry has been saved, used to execute another function or checked against our database. `; 
     this.emit(':ask', reprompt, reprompt); 
    }, 
    'ExitIntent': function() { //Sample Utterance: Exit 
     console.log("EXIT"); 
     this.handler.state = states.LOBBYMODE; 
     message = `You have returned to the lobby, continue with the app or say quit to exit.`; 
     this.emit(':ask', message, message); 
    }, 
    'RepeatIntent': function() { 
     var currentPassword = this.attributes['BUILDPASSWORD']; 
     var currentPasswordExploded = currentPassword.replace(/(.)(?=.)/g, "$1 "); //insert a space between each character so alexa reads correctly. 
     var message = ` Your current entry is as follows. `+currentPasswordExploded; 
     var reprompt = ` say complete if you've stated the whole password. Otherwise continue to say numbers letters and symbols. `; 
     this.emit(':ask', reprompt, reprompt); 
    }, 
    'Unhandled': function() { 
     console.log("UNHANDLED"); 
     var reprompt = ` You're kind of in the middle of something. Say exit to end creating this password, say complete if you've stated the whole password, say repeat to hear the current password you've entered, or continue to state letters, numbers and symbols `; 
     this.emit(':ask', reprompt, reprompt); 
    } 
}); 
相關問題