Zip-Code-Specific Address Grammar Implementation
Introduction
The use case we are examining in the document is about the usage of zip-code-dedicated ASR grammars. These grammars serve use cases where the caller needs to provide a street name and number to the speech application. To increase the accuracy of the ASR performance, the system first needs to ask for the postal code where the address belongs and then for the street name and number so as to enable a smaller recognition space.
The functionality is currently available for the OCP instances in the United States and in Germany.
Implementation Steps
Create a Numeric (or an Alphanumeric) miniApp to collect a valid zip code. Use the Validations Tab for the zip code to ensure that the numeric (or alphanumeric) sequence provided by the caller is an existing zip code.
Create an Intelli miniApp to take the zip code from the previous numeric (or alphanumeric) miniApp as an input field and return the grammar name alias
GrammarAliasName
as an output field.
The following JS sample code is used as a function at the Output tab of the intelli miniApp. It assumes that the de-DE.Addresses
(German) or en_addresses
(English - United States) or en-GB.Addresses
(English - Great Britain) are the basic names for the ASR grammars to be used for address recognition.
For en-GB, the postal code that is passed to the ASR grammar alias name should be in all capital letters. Additionally, the last 2 digits of the postal code should be removed.
var code = params.PostalCode;
// Grammar Alias for English - Great Britain implementations
// The postal code used for recognition should be in upper case and it should not include the last 2 digits
code = code.toString().slice(0, -2).replace(/\s+/g, "").toUpperCase();
var GrammarAliasName = "en-GB.Addresses?asset=ZipCode" + code + "Classes";
// Grammar Alias for German implementations
// var GrammarAliasName = "de-DE.Addresses?asset=ZipCode" + code + "Classes";
// Grammar Alias for English - United States implementations
// var GrammarAliasName = "en_addresses?asset=ZipCode" + code + "Classes";
var Outputs = {
GrammarAliasName:GrammarAliasName
}
Outputs;
Create an Entity miniApp to collect the mandatory entity
USStreet
(en-US),DEStreet
(de-DE) orUKStreet
(en-GB) and optionalStreetNumber
. Assign the field name used for the grammar name alias that was the output of your intelli miniApp (e.g.GrammarAliasName
) to theasrGrammar
miniApp input value as per the screenshot below:

Create a Universal NLU model that includes the address add-on and assign it to your Entity miniApp.

How to test
Test via phone
Use valid and invalid zip codes. The invalid zip codes should never proceed with the street name and number entity miniApp.
Test short and long variations of the address.