<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:courier,monaco,monospace,sans-serif;font-size:12pt">Yes I want to keep more modules in the svn tree<br>we have a few in the scripts subdir like scripts/js_modules/SpeechTools.jm for the asr stuff.<br><br><br><div> </div><div>Anthony Minessale II<br><br><span>FreeSWITCH <a target="_blank" href="http://www.freeswitch.org/">http://www.freeswitch.org/</a></span><br><span>ClueCon <a target="_blank" href="http://www.cluecon.com/">http://www.cluecon.com/</a></span><br><br>AIM: anthm<br>MSN:anthony_minessale@hotmail.com<br>JABBER:anthony.minessale@gmail.com<br>IRC: irc.freenode.net #freeswitch</div><div><br>FreeSWITCH Developer Conference<br>sip:888@conference.freeswitch.org<br>iax:guest@conference.freeswitch.org/888<br>googletalk:conf+888@conference.freeswitch.org<br>pstn:213-799-1400</div><div style="font-family: courier,monaco,monospace,sans-serif;
font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Jonas Gauffin <jonas.gauffin@gmail.com><br>To: freeswitch-users@lists.freeswitch.org<br>Sent: Saturday, August 11, 2007 9:08:26 AM<br>Subject: Re: [Freeswitch-users] Javascript input<br><br><div>I've written a module for the input handling and for playing phrases<br>only when dtmf digits are not pressed (which can be overridden). I got<br>a couple of OOP javascript modules (for freeswitch) that I can<br>contribute with.<br><br>Should javascript modules be checked in too? Currently there are a lot<br>of example code in the wiki, but it doesn't feel like the right place.<br>Maybe there should be some example applications and modules in the<br>repository?<br><br>for instance, my module can do this:<br><br>digit = input.getByMenu("123", "to_conference_1;to_queue_2;to_operator_3");<br><br>That creates a
complete menu that does this:<br>a) Only valid digits are 123<br>b) It plays "choice_invalid" if an invalid choice was pressed (max three times)<br>c) plays "choice_timeout" if the user do not enter anything<br>d) playes "choice_too_many_tries" if three attempts was made.<br>e) It plays all of the soundfiles that was separated with semicolon<br>f) Soundfiles that end with "_X" are handled in a special way. _X will<br>be substituted with "pressX" soundfile. i.e the following soundfiles<br>will be played: "to_conference", "press1", to_queue", "press2",<br>"to_operator", "press3". That's perfect if you got a database driven<br>menu where u want to reuse your normal sound files.<br><br>I've also made the module aware of language choice. (You can switch<br>language any time in the IVR apps).<br><br>Thanks for the answer about streamFile. I guess that a standardized<br>javascript module will do instead.<br><br>On 8/11/07, Anthony Minessale
<anthmct@yahoo.com> wrote:<br>><br>> The notion of the callback goes all the way down to the core. The C portion<br>> of the code is where the digit is dequeued so there is no way to avoid it.<br>><br>> So, When you call streamFile you can not only pass a function to callback,<br>> you can also pass an arbitrary object. That way you can get that object as<br>> "arg" in your example callback and push the digits onto a shared string<br>> there.<br>><br>><br>> The intention is to make a pure js class for this kind of thing that we can<br>> put in tree and people can use it to make their scripts.<br>><br>><br>><br>> function mycb (type, data, arg) {<br>><br>> if (type == "dtmf") {<br>> arg.digits += data;<br>> return false;<br>> }<br>> }<br>><br>> var dtmf = new Object();<br>> dtmf.digits = "";<br>>
session.streamFile("blah.wav", mycb, dtmf);<br>> //say you need 3 digits so subtract how many you have so far.<br>> dtmf.digits += getDigits(3 - dtmf.digits.length, "#", 5000);<br>><br>> This is a crude example but you can see how you could write this into a<br>> permanently used module everyone could use. The idea is to make the js the<br>> place where you can continue to code functionality without touching the<br>> core. That is the reason the default api is the lowest level possible<br>> without going too far.<br>><br>> This pure js module has yet to be written but we probably should get started<br>> on it soon before we make everyone duplicate this kind of thing....<br>><br>><br>> Anthony Minessale II<br>><br>> FreeSWITCH <a target="_blank" href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>> ClueCon <a target="_blank"
href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>><br>> AIM: anthm<br>> MSN:anthony_minessale@hotmail.com<br>> JABBER:anthony.minessale@gmail.com<br>> IRC: irc.freenode.net #freeswitch<br>><br>> FreeSWITCH Developer Conference<br>> sip:888@conference.freeswitch.org<br>> iax:guest@conference.freeswitch.org/888<br>> googletalk:conf+888@conference.freeswitch.org<br>> pstn:213-799-1400<br>><br>><br>> ----- Original Message ----<br>> From: Jonas Gauffin <jonas.gauffin@gmail.com><br>> To: freeswitch-users@lists.freeswitch.org<br>> Sent: Saturday, August 11, 2007 3:37:26 AM<br>> Subject: Re: [Freeswitch-users] Javascript input<br>><br>> Ok. Let's take an example:<br>><br>> I got a voicemail application that plays a lot of phrases. Let's check<br>> a simple example:<br>><br>> session.streamFile("you_have.wav");<br>> session.streamFile("2.wav");<br>>
session.streamFile("new_messages.wav");<br>> choice = session.getDigit(1, "", 5000);<br>><br>> Ok. I want to skip to the second voicemail by pressing 2. That's not<br>> possible with the code above. Instead you have to do something like<br>> this:<br>><br>> var _digits = "";<br>> function on_dtmf(type, digits, arg)<br>> {<br>> _digits += digits;<br>> return false;<br>> }<br>><br>> function say(phrase)<br>> {<br>> if (_digits != "")<br>> return false;<br>> session.streamFile(phrase, on_dtmf);<br>> }<br>><br>> function getDigits(length, terminators, timeout)<br>> {<br>> if (_digits != '')<br>> {<br>> var tempVar = _digits;<br>> _digits = "";<br>> return tempVar;<br>> }<br>> return
session.getDigits(length, terminators, timeout);<br>> }<br>><br>> say("you_have.wav");<br>> say("2.wav");<br>> say("new_messages");<br>> choice = getDigits(1, "", 5000);<br>><br>> Right? That will abort speach on input and return the pressed digit.<br>> But what if we want to enter a pincode or something like that? Then we<br>> need to handle both _digits AND use session.getDigits:<br>><br>> function getDigits(length, terminators, timeout)<br>> {<br>> if (_digits.length < length)<br>> {<br>> tempVar = _digits;<br>> _digits = "";<br>> tempVar += session.getDigits(length - _digits.length, terminators,<br>> timeout);<br>> return tempVar;<br>> }<br>> else<br>> {<br>> tempVar =
_digits;<br>> _digits = "";<br>> return tempVar;<br>> }<br>> }<br>><br>> Get my point? All of that could have been two lines of code if there<br>> was an alternative to streamFile which do not remove the DTMF from the<br>> input queue (or whatever it's called):<br>><br>> session.streamAndAbortOnDtmf("theFile.wav");<br>> var digit = session.getDigits(1, "", 3000);<br>><br>> All I wanted was an alternative that is simple. Again: I'm not looking<br>> for a replacement of streamFile but an complement for those who just<br>> want to do the above.<br>><br>> I apologize if my examples are incorrect in some way, I've written<br>> them directly in this email with my mind as a reference. I might have<br>> done some syntax errors or something like that. Afterall, it's<br>> saturday =)<br>><br>> But anyway. I can create an alternative to
streamFile which does<br>> On 8/10/07, Chris Danielson <chris@maxpowersoft.com> wrote:<br>> > Jonas,<br>> > To what purpose would having a streamFile abort without DTMF input? If<br>> > the streamFile operation is going to require aborting then DTMF input or<br>> > voice recognition will be the means. Jonas, your heart is in the right<br>> > place, but everything you have asked for is already implemented in a very<br>> > flexible manner within the JavaScript engine.<br>> > Regards,<br>> > Chris Danielson<br>> ><br>> > > Yes. The current architecture works just fine.<br>> > ><br>> > > I'm not saying that the current method should be removed. It's<br>> > > excellent in those cases when you want to filter input during<br>> > > streamFile and recordFile. But I still think that those cases are more<br>> > > rare than
wanting to abort the speech.<br>> > ><br>> > > Consider this a feature request then: A new streamFile that do not eat<br>> > > DTMF but aborts the speech instead. Or simply a new argument that<br>> > > specifies that the method should abort instead of eating the DTMF.<br>> > ><br>> > > On 8/10/07, Mike Murdock <mmurdock@coppercom.com> wrote:<br>> > >> You do currently have the option to either continue playing the prompt<br>> > >> or abort the prompt. In order to collect the digits during the playing<br>> > >> of a prompt you must code a dtmf_callback handler. When a user presses<br>> a<br>> > >> digit your call back handler gets called. You can decide it the digit<br>> is<br>> > >> a valid one and if it is valid return "false" (or the digit) causing<br>> the<br>> > >> prompt to stop. If the digit is not valid you
can ignore it by<br>> returning<br>> > >> "true" and the prompting will continue. While this does require the<br>> > >> application developer to code a digit handler it gives you a much<br>> richer<br>> > >> option for the handling of the results.<br>> > >><br>> > >> You are free to develop your own wrapper function to force the<br>> > >> particular behaviour you want. I have written a getdigits function in<br>> > >> javascript that you are welcome to use to get the behaviour you are<br>> > >> looking for.<br>> > >><br>> > >><br>> > >> Michael B. Murdock<br>> > >><br>> > >><br>> > >><br>> > >> ________________________________<br>> > >><br>> > >> From: freeswitch-users-bounces@lists.freeswitch.org on<br>> behalf of Jonas<br>> > >>
Gauffin<br>> > >> Sent: Fri 8/10/2007 2:49 AM<br>> > >> To: freeswitch-users@lists.freeswitch.org<br>> > >> Subject: Re: [Freeswitch-users] Javascript input<br>> > >><br>> > >><br>> > >><br>> > >> Why not simply make another streamFile method that aborts on input.<br>> > >> Then the user can choose which one he wants.<br>> > >><br>> > >> I can elaborate my wish too. I guess that you have used a lot of IVR<br>> > >> applications, right?<br>> > >> For instance, you call your phone provider and they have a IVR m<br>> ><br>> ><br>> > _______________________________________________<br>> > Freeswitch-users mailing list<br>> > Freeswitch-users@lists.freeswitch.org<br>> ><br>> <a target="_blank"
href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>> ><br>> UNSUBSCRIBE:<a target="_blank" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>> > <a target="_blank" href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>> ><br>><br>> _______________________________________________<br>> Freeswitch-users mailing list<br>> Freeswitch-users@lists.freeswitch.org<br>> <a target="_blank" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>> UNSUBSCRIBE:<a target="_blank" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>> <a target="_blank"
href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>><br>><br>> ________________________________<br>> Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail,<br>> news, photos & more.<br>> _______________________________________________<br>> Freeswitch-users mailing list<br>> Freeswitch-users@lists.freeswitch.org<br>> <a target="_blank" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>> UNSUBSCRIBE:<a target="_blank" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>> <a target="_blank" href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>><br>><br><br>_______________________________________________<br>Freeswitch-users mailing list<br>Freeswitch-users@lists.freeswitch.org<br><a
target="_blank" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>UNSUBSCRIBE:<a target="_blank" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br><a target="_blank" href="http://www.freeswitch.org">http://www.freeswitch.org</a><br></div></div><br></div></div><br>
<hr size=1>Yahoo! oneSearch: Finally, <a href="http://us.rd.yahoo.com/evt=48252/*http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC"> mobile search
that gives answers</a>, not web links.
</body></html>