Playback numeric values

166 views
Skip to first unread message

AshikAli.m

unread,
Aug 31, 2010, 7:46:52 AM8/31/10
to adhea...@googlegroups.com
Hi all,

I am using   Asterisk 1.6.2.10
                   Adhearsion 0.8.5

So I enabled   config.enable_asterisk :argument_delimiter => ','

In the extensions.conf  file:

[from-internal-custom]
exten => 1234,1,agi(agi://192.168.1.60/from_internal)
exten => 1235,1,festival(This-is-for-testing)
exten => 5678,1,playback(num:344345,say)
exten => 5678,n,hangup

When I am dialing out 5678 asterisk executes corresponding settings in say.conf well.

Anybody have experienced how to achieve same in adhearsion-0.8.5 ?

In dialplan.rb:

 play "num:344345,say"  has been interpreted as follows


DEBUG agi: >>> ANSWER
DEBUG agi: <<< 200 result=0

DEBUG agi: >>> STREAM FILE "first-menu" "1234567890*#"
DEBUG agi: <<< 200 result=49 endpos=14880

DEBUG db:   SmsserverCall Load (7.0ms)   SELECT * FROM `smsserver_calls`
DEBUG agi: >>> EXEC playback "num:43567,say"
DEBUG agi: <<< 200 result=0

DEBUG agi: >>> EXEC playback "you-sound-cute"
DEBUG agi: <<< 200 result=0


But it sounds nothing.

Thanks&Regards,
Ashik
--
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
                                                                    – Antoine de Saint-Exupery

Ben Langfeld

unread,
Aug 31, 2010, 7:53:44 AM8/31/10
to adhea...@googlegroups.com
You can just do:

say 43567

and Adhearsion will work it all out for you. If you pass it as an integer, as in that example, it will read one digit at a time. Passed as a string, it will read as "forty-three thousand five hundred and sixty seven".

Regards,
Ben Langfeld


--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To post to this group, send email to adhea...@googlegroups.com.
To unsubscribe from this group, send email to adhearsion+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/adhearsion?hl=en.

Ben Langfeld

unread,
Aug 31, 2010, 7:56:29 AM8/31/10
to adhea...@googlegroups.com
Of course, that should actually have been:

play 43567

Regards,
Ben Langfeld

Ben Klang

unread,
Aug 31, 2010, 10:34:32 AM8/31/10
to adhea...@googlegroups.com
This is correct with a couple of small corrections.  Adhearsion does detect the type of variable passed to "play".  The following are valid:

play "sound_file" (String obj): Adhearsion will instruct Asterisk to play the file named "sound file"
play 12345 (Numeric obj): Adhearsion will instruct Asterisk to "say number", resulting in "12 thousand 3 hundred forty-five"
play Time.now (Time obj): Adhearsion will instruct Asterisk to play the specified time/date

/BAK/

AshikAli.m

unread,
Sep 1, 2010, 1:49:05 AM9/1/10
to adhea...@googlegroups.com
Hi all,

I am able to understand your solutions.

In  India although we speak UK,US english there is some changes in numbering system. For example
let us take the number 123456.

               UK,US interpretation is  => One hundred twenty three thousand four hundred fifty six  => this is what play 123456 does
                India   interpretation is  =>  1 lack twenty three thousand four hundred fifty six .

After configuring say.conf. I am able to get this working with playback(num:123456,say) when I am writing it in dialplan.
Regarding this I wrote blog   http://asterisknumbertovoice.blogspot.com/ .

Does anybody have solutions to have this in adhearsion ?.

Thanks,
Ashik

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
                                                                    – Antoine de Saint-Exupery



Aldo Bergamini

unread,
Sep 1, 2010, 5:20:27 AM9/1/10
to adhea...@googlegroups.com
On 1 Sep 2010, at 07:49, AshikAli.m wrote:

> Hi all,
>

> I am able to understand your solutions.
>
> In India although we speak UK,US english there is some changes in numbering system. For example
> let us take the number 123456.
>
> UK,US interpretation is => One hundred twenty three thousand four hundred fifty six => this is what play 123456 does
> India interpretation is => 1 lack twenty three thousand four hundred fifty six .
>
> After configuring say.conf. I am able to get this working with playback(num:123456,say) when I am writing it in dialplan.
> Regarding this I wrote blog http://asterisknumbertovoice.blogspot.com/ .
>
> Does anybody have solutions to have this in adhearsion ?.
>
> Thanks,
> Ashik

Hi Ashik,

out of pure curiosity: how are you writing what is the UK/US meant number 123456?
("One hundred twenty" etc)

Fascinating (as 'completely unexpected') piece of information!

Kind regards,
Aldo

AshikAli.m

unread,
Sep 2, 2010, 2:07:13 AM9/2/10
to adhea...@googlegroups.com
hi Aldo and all,

Something we are getting out from the topic. Pl understand what is important here.

I am thinking all about to get this working in adhearsion. I have to update it to my blog.

Thanks,
Ashik


Aldo Bergamini

unread,
Sep 2, 2010, 4:17:57 AM9/2/10
to adhea...@googlegroups.com
On 2 Sep 2010, at 08:07, AshikAli.m wrote:

> hi Aldo and all,
>
> Something we are getting out from the topic. Pl understand what is important here.
>
> I am thinking all about to get this working in adhearsion. I have to update it to my blog.
>
> Thanks,
> Ashik


Hi Ashik,

sorry for the off-topic excursion.

In the meantime I did the 'clever' thing and looked up the matter on Wikipedia. I understand now that I was completely wrong in the idea I had about the numbers w. "India interpretation".

The word 'lack' was unheard to me...

Actually I guess that other (UK, US, etc) people have no idea about what are the pronunciation / number parsing rules you are looking to implement in Adhearsion ...

So that this link might help:

http://en.wikipedia.org/wiki/South_Asian_numbering_system

BTW, the article says at the end: "Instead of saying the higher numbers, it is more common to use lakh and crore repeatedly or in combination, saying 1 lakh crore for 1012 or one trillion".

Do you have the need to follow this convention?

Because while it could be relatively simple to replace the 'hundred' uttering with a 'lack' vocal uttering, while maintaining the same token (like you do when you add a language in the Asterisk sounds setup) I guess it might be less straightforward to compute the right amount and combination of 'lacks&crores'.

Kind regards,
Aldo

Ben Klang

unread,
Sep 2, 2010, 7:57:41 AM9/2/10
to adhea...@googlegroups.com
On Sep 1, 2010, at 1:49 AM, AshikAli.m wrote:

Hi all,

I am able to understand your solutions.

In  India although we speak UK,US english there is some changes in numbering system. For example
let us take the number 123456.

               UK,US interpretation is  => One hundred twenty three thousand four hundred fifty six  => this is what play 123456 does
                India   interpretation is  =>  1 lack twenty three thousand four hundred fifty six .

After configuring say.conf. I am able to get this working with playback(num:123456,say) when I am writing it in dialplan.
Regarding this I wrote blog   http://asterisknumbertovoice.blogspot.com/ .

As you discuss in your blog post, the place to configure this is in Asterisk, not Adhearsion.  Adhearsion does not manage the audio files Asterisk selects for multi-language systems.  Adhearsion can set the variables (such as LANGUAGE) which will tell Asterisk to use a different set of audio prompts.

I have not tried to localize numbers like you have, but based on my reading of Asterisk 1.6's say.conf it should be possible by matching the language code to a say.conf context.  The blog post mentioned a syntax that is not documented in Asterisk 1.6 so I am assuming that it is valid for Asterisk 1.4.  I do not know whether it is possible to get it to work with Asterisk 1.4 if you have to use the "Playback" function.

As a workaround, you can use the following in Adhearsion:
execute "Playback", "num:123456789", "say"

/BAK/ 

AshikAli.m

unread,
Sep 6, 2010, 2:39:18 AM9/6/10
to adhea...@googlegroups.com
Hi ben and all,

Thanks for your suggestions. But it sounds nothing. Shall we proceed it as asterisk agi  bug ?  because it is working well when we write it in dialplan why not agi.

Thanks,
Ashik

Ben Klang

unread,
Sep 6, 2010, 10:44:36 AM9/6/10
to adhea...@googlegroups.com
On Sep 6, 2010, at 2:39 AM, AshikAli.m wrote:

Hi ben and all,

Thanks for your suggestions. But it sounds nothing. Shall we proceed it as asterisk agi  bug ?  because it is working well when we write it in dialplan why not agi.

Can you let us know what exactly you tried?  I don't have reason to suspect an AGI error at this point.  Please paste what you put in extensions.conf (that does work) vs. what you put in dialplan.rb (that does not work).

/BAK/

AshikAli.m

unread,
Sep 7, 2010, 3:21:34 AM9/7/10
to adhea...@googlegroups.com
Hi all,

Suspecting Agi Error:

Testing on extensions.conf which is working well :


[from-internal-custom]
exten => 1234,1,agi(agi://192.168.1.60/from_internal)
exten => 5678,1,playback(num:344345,say)
exten => 5678,n,hangup


asterisk console output:


When I am dialing out 5678 ,


elastix*CLI>
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Executing [5678@from-internal:1] Playback("SIP/6000-00000001", "num:344345,say") in new stack
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/3.gsm' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/lack.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/40.gsm' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/4.gsm' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/thousand.gsm' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/3.gsm' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/hundred.gsm' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/40.gsm' (language 'en')
    -- <SIP/6000-00000001> Playing 'silence/0.5.slin' (language 'en')
    -- <SIP/6000-00000001> Playing 'digits/5.gsm' (language 'en')
    -- Executing [5678@from-internal:2] Hangup("SIP/6000-00000001", "") in new stack

I am able to hear "three lack forty four thousand three hundred forty five" as per say.conf as follows.

 say.conf:

[en-base](!)
    _[n]um:0. =>      num:${SAY:1}
    _[n]um:Z  =>      silence/0.5,digits/${SAY}
    _[n]um:1X =>      silence/0.5,digits/${SAY}
    _[n]um:[2-9]0 =>  silence/0.5,digits/${SAY}
    _[n]um:[2-9][1-9] =>  silence/0.5,digits/${SAY:0:1}0, num:${SAY:1}
    _[n]um:XXX => num:${SAY:0:1}, silence/0.5,digits/hundred, num:${SAY:1}

    _[n]um:XXXX => num:${SAY:0:1}, silence/0.5,digits/thousand,  num:${SAY:1}
    _[n]um:XXXXX => num:${SAY:0:2},silence/0.5, digits/thousand, num:${SAY:2}

    _[n]um:XXXXXX => num:${SAY:0:1},silence/0.5, digits/lack, num:${SAY:1}
    _[n]um:XXXXXXX => num:${SAY:0:2},silence/0.5, digits/lack, num:${SAY:2}

    _[n]um:XXXXXXXX => num:${SAY:0:1},silence/0.5, digits/crore, num:${SAY:1}
    _[n]um:XXXXXXXXX => num:${SAY:0:2},silence/0.5, digits/crore, num:${SAY:2}
    _[n]um:XXXXXXXXXX => num:${SAY:0:3}, silence/0.5,digits/crore, num:${SAY:3}
    _[n]um:XXXXXXXXXXX => num:${SAY:0:4}, silence/0.5,digits/crore, num:${SAY:4}
    _[n]um:XXXXXXXXXXXX => num:${SAY:0:5}, silence/0.5,digits/crore, num:${SAY:5}


In dialplan.rb:      

 execute "Playback", "num:344345", "say"

Adhearsion debug output:

when I am dialing out 1234

[Tue Sep  7 12:42:00 2010] Adhearsion::VoIP::Asterisk::AGI::Server::RubyServer 0.0.0.0:4573 client:50160 192.168.1.60<192.168.1.60> connect
DEBUG agi: Handling call with variables {:network=>true, :network_script=>"from_internal", :request=>#<URI::Generic:0x6e3fe4 URL:agi://192.168.1.60/from_internal>, :channel=>"SIP/6000-00000002", :language=>"en", :type=>"SIP", :uniqueid=>"1283843519.2", :version=>"1.6.2.10", :callerid=>6000, :calleridname=>"device", :callingpres=>0, :callingani2=>0, :callingtns=>0, :dnid=>1234, :rdnis=>nil, :context=>"from_internal", :extension=>1234, :priority=>1, :enhanced=>0.0, :accountcode=>"", :threadid=>-1217918064, :query=>{}, :type_of_calling_number=>:unknown}

DEBUG agi: >>> ANSWER
DEBUG agi: <<< 200 result=0

DEBUG agi: >>> STREAM FILE "first-menu" "1234567890*#"
DEBUG agi: <<< 200 result=0 endpos=36482

DEBUG agi: >>> WAIT FOR DIGIT "8000"
DEBUG agi: <<< 200 result=49

DEBUG agi: >>> EXEC Playback "num:123457","say"

DEBUG agi: <<< 200 result=0

DEBUG agi: >>> EXEC playback "you-sound-cute"
DEBUG agi: <<< 200 result=0

Asterisk console agi debug :

<SIP/6000-00000002>AGI Tx >> 200 result=0
<SIP/6000-00000002>AGI Rx << STREAM FILE "first-menu" "1234567890*#"
    -- Playing 'first-menu' (escape_digits=1234567890*#) (sample_offset 0)
<SIP/6000-00000002>AGI Tx >> 200 result=0 endpos=36482
<SIP/6000-00000002>AGI Rx << WAIT FOR DIGIT "8000"
<SIP/6000-00000002>AGI Tx >> 200 result=49
<SIP/6000-00000002>AGI Rx << EXEC Playback "num:123457","say"
    -- AGI Script Executing Application: (Playback) Options: (num:123457,say)
<SIP/6000-00000002>AGI Tx >> 200 result=0
<SIP/6000-00000002>AGI Rx << EXEC playback "you-sound-cute"
    -- AGI Script Executing Application: (playback) Options: (you-sound-cute)
    -- <SIP/6000-00000002> Playing 'you-sound-cute.gsm' (language 'en')
<SIP/6000-00000002>AGI Tx >> 200 result=0
    -- <SIP/6000-00000002>AGI Script agi://192.168.1.60/from_internal completed, returning 0


Except red shadowed all are playing well. What we do ?

Thanks,
Ashik Ali

--
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
                                                               – Antoine de Saint-Exupery

AshikAli.m

unread,
Aug 21, 2011, 8:41:47 AM8/21/11
to adhea...@googlegroups.com
Hi all,

It was about to one year back, I opened this issue.  Now I tested this issue with 1.8,1.6 and 1.4  version of asterisk.  Everything is working fine.
Here-after we can make asterisk to speak our regional number,date and time on AGI.


On AGI:

On 1.8 and above:

#!/usr/bin/perl -w

use Asterisk::AGI;

my $AGI = new Asterisk::AGI,$result;
#for number
$AGI->exec("PLAYBACK num:2415312511,say \"\"\n");
#for date
$AGI->exec("PLAYBACK datetime::201104172030.00-4-102,say \"\"\n"); # for date
exit;

On 1.4 and 1.6 :

Although asterisk version is 1.6 we have to use '|'  rather than ',' .


#!/usr/bin/perl -w

use Asterisk::AGI;

my $AGI = new Asterisk::AGI,$result;
#for number
$AGI->exec("PLAYBACK num:2415312511|say \"\"\n");
# for date
$AGI->exec("PLAYBACK datetime::201104172030.00-4-102|say \"\"\n");
exit;



Currently I have created settings for Indian English and Arabic. Those who want to configure this functionality on asterisk pl have look on my blog.

http://asterisknumbertovoice.blogspot.com/2010/05/asterisk-number-to-voice-configuration.html.


Thanks & Regards,
  Ashik Ali
--
Reply all
Reply to author
Forward
0 new messages