[Asterisk-Dev] internationalisation of voice-prompts

Paul Crick web-asterisk-dev at ivrl.com
Fri Oct 24 13:32:23 MST 2003


In my previous job I used Intel's CT-ADE, formerly VOS from Parity Software.
With their newer releases they introduced the Topaz layer which does a lot
of abstraction and this is one area where they applied it - grammars and
languages. 95 = "Ninety five" in English (with my preference being the
prompt recorded as "Ninety five" not played as "Ninety".. "Five"..) but in
French it's like "Four Twenty Fifteen" or something..

I was going to copy'n'paste the manual page on how they do it with flexible
grammars (so you can define your own if nothing they've got there exists
already) but the formatting doesn't come across too well. Instead, here's a
snippet that kind of explains how they do it.. the premise is that you call
a function like MediaPlayNumber(12345) and the grammar rules define how the
digits are grouped/spoken back.

(HOLY - hard work editing the formatting, and hopefully it makes sense.. I
can understand what they've done and how.. makes it kind of flexibile, but I
got to admit we never used these functions, we just wrote our own as we had
other value giving prompts (like money with decimals etc or floating point..
The value 3.127 becomes "three"  "point one"  "two"  "seven" - sounds great)

--- snip ---

Examples
Let's step through part of the grammar section of the U.S. English language
profile.

<grammar>

%Numbers   ,             , Zero
%$1$0      ,             , Zero
%Restart10 ,             ,
	   ,         ??  , Numbers[2+1]
 	   ,        ???  , Numbers[3];Hundred;%Restart10(2+1)
	   ,     ??????  , %Restart10(6+4);Thousand;%Restart10(3+1)
	   ,  ?????????  , %Restart10(9+7);Million;%Restart10(6+1)
	   , ??????????  , Numbers[10];Billion;%Restart10(9+1)
	   ,          &  , !

</grammar>


Example 1: Type = 1, Gender = 0, Value = 0
When VOS plays a phrase element with Type = 1 (numbers) and Gender = 0
(neuter), then Topaz jumps to the %$1$0 label:

%$1$0      ,    ,               Zero

The pattern to match in this line is blank, equal to an empty string, or any
number of zeroes that aren't followed by another digit. (Since leading
zeroes are dropped, a Value like "0" or "0000" becomes an empty string.)
Since the Value matches the pattern, Topaz follows the rule given on this
line, using the vocabulary entry labeled Zero to find the prompt to play.
(In the U.S. English language profile, the Zero entry points to a prompt
that says "zero.")



Example 2: Type = 1, Gender = 0, Value = 5

As before, Topaz first jumps to the %$1$0 label.

%$1$0      ,    ,               Zero

Since the Value isn't an empty string or 0, Topaz moves to the next line,
labeled %Restart10:

%Restart10 ,    ,

The pattern to match for this line is also an empty string (We'll see why
this line has been included in Example.4), so Topaz moves to the next line:

           ,            ?? , Numbers[2+1]

The pattern to match on this line is two question marks, which represent any
two characters or less. The Value does match this pattern, so Topaz follows
the rule on this line before returning. The rule to follow is a single
reference to a vocabulary entry:

Numbers[2+1]

which means that the character in the first and second positions is used
with the Numbers vocabulary entry to determine which prompt to play. In this
case just the number 5, which is in the first position, is used with the
Numbers vocabulary entry since there is no character in the second position.



Example 3: Type = 1, Gender = 0, Value = 735

As before, Topaz first jumps to the %$1$0 label. Since the Value isn't an
empty string or 0, Topaz moves to the next line, labeled %Restart10. The
pattern to match for this line is also an empty string, so Topaz moves to
the next line. Since the Value has three characters, Topaz continues through
the next lines until it reaches the first matching pattern:

???

The rule on this line is

Numbers[3];Hundred;%Restart10(2+1)

The first reference -- Numbers[3] -- says that the character in the third
position from the right (7) is used with the Numbers vocabulary entry to
specify the first prompt. (This will say the word "seven" -- for more on
reading vocabulary entries, see Vocabularies and Interpreting Grammar
References in Vocabulary Entries.)

The second reference points to a vocabulary entry called Hundred, with no
offset. (This will say the word "hundred.")

The third reference tells Topaz to jump to the %Restart10 label and process
the second and first characters from the right, in this case the 3 and 5.
Topaz jumps to the %Restart10 label and tries to match the pattern to the
remaining value, 35. Topaz compares the patterns until it finds one that
matches:

??

The rule that corresponds to this pattern is:

Numbers[2+1]

The reference says that the characters in the second and first positions
from the right (3 and 5) are used with the Numbers vocabulary entry to
specify the prompt. (This will say the word "thirty-five.")

In this example, you can see how a rule's references ultimately lead to
vocabulary entries. The first rule we encountered contained two vocabulary
entries and jumped to a grammar label with the last two digits. The rule
that was assigned to those digits contained a vocabulary.

???
 ??

Numbers[7]

Hundred

%Restart10(2+1)
 Numbers[35]




More information about the asterisk-dev mailing list