[Freeswitch-users] using keypress to stop a recording.

Michael Collins msc at freeswitch.org
Sat Jun 18 08:01:11 MSD 2011


On Thu, Jun 16, 2011 at 2:52 PM, Wes <wes-fs at 499x.com> wrote:

> **
> ok, tried that, but it didn't change the behavior  In fact, I removed both
> the onInput function, and the call to session:setVariable, and the recording
> is still halted by *any* keypress on the keypad.  So this must be the
> default behavior of how to stop the recording...
>
> Can anyone confirm this?
>
> I can. It does indeed always stop the recording. Not sure why. However,
there is a simple workaround. Instead of using setInputCallback just do
this:

session:setVariable('playback_terminators','#');
session:execute('record','/tmp/foo.wav');

You would, though, need to setInputCallback while you are playing the
followup message to the caller. BTW, if you have the FS book I did an
example of this, in Lua, where the caller records something then he can
listen, accept, or re-record. Check out chapter 7. FYI, download the code
samples because there's a bug in the text. (Missing the session:ready()
check on one or more while loops, IIRC.)

-MC


> Thanks.
>
>
>
> On 6/16/2011 4:32 PM, Michael Collins wrote:
>
> It's just a channel variable. Set it prior to calling the Lua script or use
> session:setVariable("playback_terminators","#")
>
>  -MC
>
> On Thu, Jun 16, 2011 at 2:29 PM, Wes <wes-fs at 499x.com> wrote:
>
>>  I'm writing a lua script, that link you mention doesn't seem like
>> something I can do in LUA...
>>
>> the problem is in this function:
>>
>>
>> function onInput(s, type, obj)
>>   if (type == "dtmf" and obj['digit'] == '#') then
>>       return "break";
>>   end
>> end
>>
>>  which seems to break on any keypress, so the check for # doesn't work as
>> expected.
>>
>> is there a different way to do this with a lua script?  Ideally, I'd like
>> to do more than just break, I'd like the user to be able to review the
>> message more than once, and then finally hit another key to submit it for
>> real.  Like a voicemail system, actually.
>>
>>
>> On 6/16/2011 3:55 PM, Michael Collins wrote:
>>
>>  How about setting this only to #?
>> http://wiki.freeswitch.org/wiki/Channel_Variables#playback_terminators
>>
>>  -MC
>>
>> On Thu, Jun 16, 2011 at 11:54 AM, Wes <wes-fs at 499x.com> wrote:
>>
>>> I'm using the following script to record, and I"m hoping to take a user
>>> keypress to trigger the end of the recording and then play it back:
>>>
>>> (the problem is that it stops on ANY keypress, while it seems like it
>>> should only break on a "#" keypress)
>>>
>>> I found this example at:
>>> http://wiki.freeswitch.org/wiki/Mod_lua#session:recordFile
>>>
>>> local numberToCall = 1234
>>> local session =
>>> freeswitch.Session("sofia/xxx.xxx.xxx.xxx/"..numberToCall);
>>> session:set_tts_parms("flite", "kal");
>>> session:speak("Thank you for using my recording service, press the pound
>>> key to stop the recording."  );
>>>
>>> function onInput(s, type, obj)
>>>   if (type == "dtmf" and obj['digit'] == '#') then
>>>       return "break";
>>>   end
>>> end
>>>
>>> session:setInputCallback("onInput", "");
>>> session:recordFile("/tmp/luatest.wav");
>>> freeswitch.consoleLog("info", "recording stopped by user keypress \n");
>>> session:speak("your voicehas been recorded, i will play it for you now");
>>> session:streamFile("/tmp/luatest.wav");
>>> session:speak("that's it, goodbye.");
>>> freeswitch.consoleLog("info", "hanging up... \n");
>>> session:hangup();
>>>
>>>
>>> _______________________________________________
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>
>>
>> _______________________________________________
>> Join us at ClueCon 2011, Aug 9-11, Chicagohttp://www.cluecon.com 877-7-4ACLUE
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org
>>
>>
>> _______________________________________________
>> Join us at ClueCon 2011, Aug 9-11, Chicago
>> http://www.cluecon.com 877-7-4ACLUE
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
> _______________________________________________
> Join us at ClueCon 2011, Aug 9-11, Chicagohttp://www.cluecon.com 877-7-4ACLUE
>
> FreeSWITCH-users mailing listFreeSWITCH-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org
>
>
> _______________________________________________
> Join us at ClueCon 2011, Aug 9-11, Chicago
> http://www.cluecon.com 877-7-4ACLUE
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110617/1723692f/attachment.html 


More information about the FreeSWITCH-users mailing list