Reading phone number the French way?

Home » Asterisk Users » Reading phone number the French way?


I need to write a script which prompts the callee to type a number,
and then read it back to them as confirmation:

======= extensions.conf
;Expect 10-digit number excluding final #, 2 tries, 20s time-out
exten => s,n(nbr2call),Read(NBR2CALL,please-type-number,10,,2,20)

exten => s,n,GotoIf($[${LEN(${NBR2CALL})} != 10]?end)
;exten => s,n,SayDigits(${NBR2CALL})
exten => s,n,SayNumber(${NBR2CALL})

exten => s,n(end),Hangup()

Besides the fact that my Asterisk setup only has US sound files in
/var/lib/asterisk/sounds/digits/, I was wondering how to get Asterisk
to read back the number the French way, ie. digits are read by pairs
to the exception of the leading tuple that always starts with 0.

For instance, a landline number in Paris like 01 42 92 81 00 is read
“zero-one, forty-two, ninety-two, eighty-one, zero-zero”, where I
assume Americans would read all the digits individually (“zero, one,
four, two, etc.”)

Has someone already looked into this and knows how to solve it?

Thank you.

6 thoughts on - Reading phone number the French way?

  • Actually, the right way to do this is:

    The “LANGUAGE” pseudo-variable is read-only.

  • Also note that Asterisk will use French number saying rules as long as
    the language (the “LANGUAGE” pseudo variable) is “fr” or its prefix
    (anything up to the first ‘_’) is “fr”.

    If you want to test that, try on a system with no French prompts but
    with the standard English ones:

    ln -s en /var/lib/asterisk/sounds/fr

    Or alternatively:

    ln -s en /var/lib/asterisk/sounds/fr_WhatEver

    Now set the language (as described above) to ‘fr_WhatEver’ and try using
    SayNumber. e.g.:

    channel originate SIP/yourphone Application SayNumber 245

    I figure a prompt or two will be missing.

  • On Tue, 08 Mar 2011 13:22:18 +0100, Gilles

    Apparently, the right way to read a phone number back to the user is
    not to use SayNumber() (which might be OK for US-style reading) but
    rather Playback(:,say), which will then rely on

    For instance:
    ======= extensions.conf
    exten => 2222,1,Set(NBR2CALL=0142928100) ;exten =>
    2222,n,SayNumber(${NBR2CALL}) exten =>

    Using this almost works:
    ======= say.conf
    _pho[n]e:0[1-9]XXXXXXXX => num:${SAY:0:1}, num:${SAY:1:1},
    num:${SAY:2:2}, num:${SAY:4:2}, num:${SAY:6:2}, num:${SAY:8:2}

    The remaining problem is when a couple starts with a zero, eg. 01
    (should be read “zero one”): In this case, Asterisk ignores the
    leading zero and simply pronounces the second digit (“one”)

    Does someone know of a trick so that the pattern handles couples that
    have a leading zero?

    Thank you.

  • Look at the GotoIf statement for example

    exten => _9X.,1,GotoIf($[“${EXTEN:1:2}” = “00”]?ft)
    exten => _9X.,n,GotoIf($[“${EXTEN:1:2}” = “08”]?ft)
    exten => _9X.,n,GotoIf($[“${EXTEN:1:2}” = “06”]?ft)
    exten => _9X.,n,GotoIf($[“${EXTEN:1:1}” = “3”]?ft)
    exten => _9X.,n,GotoIf($[“${EXTEN:1:1}” = “1”]?ft)
    exten => _9X.,n,GotoIf($[“${TMP:0:2}” != “OK”]?ft)
    exten => _9X.,n, …
    exten => _9X.,n(ft), …


  • On Thu, 10 Mar 2011 13:18:41 +0100, Dave Cotton

    Thanks Dave for the tip, but I found that I needed to change a pattern
    that was already in say.conf:

    [fr](date-base,digit-base) ;BAD _[n]um:0. => num:${SAY:1}
    _[n]um:0X => num:${SAY:0:1}, num:${SAY:1:1}

    ;regular phone numbers : landlines and cellphones
    ;_pho[n]e:0[1-9]XXXXXXXX => num:${SAY:0:1}, num:${SAY:1:1},
    num:${SAY:2:2}, num:${SAY:4:2}, num:${SAY:6:2}, num:${SAY:8:2}

    If I got it right, the way say.conf works, is that it reads the whole
    say.conf to make a list of the different patterns. Then, when reading
    a prefix+number, it reads the patterns on the right side and tries to
    find if it furthers matches another pattern.

    In the example above, “_[n]um:0X” will match “num:${SAY:6:2}”, which
    will read the two digits as expected, ie. without ignoring a leading

    Thank you.