[Freeswitch-users] session.recordFile create empy wav in whileloop

Daniel Knoll daniel at danielknoll.de
Thu Jul 14 20:18:24 MSD 2011


Hey Anthony,
flushing the audio buffer before recording was the right key. Works well.

Thank you, Steve and Jason for helping me.
I'm happy like a child.

Daniel


Am 14.07.2011 um 17:56 schrieb Anthony Minessale:

> seems like speechtools.jm and mod_flite "see pizza demo" would be a
> little easier.
> 
> Anyway,
> Try session.execute("sleep", "100"); each time before you record to
> flush the audio buffers.
> 
> On Thu, Jul 14, 2011 at 10:49 AM, Daniel Knoll <daniel at danielknoll.de> wrote:
>> Hello Jason,
>> Thank you for your help. Both of them improved the code. Closing the open
>> file handle is very good, because i saw in the process view many "sh"
>> processes.
>> But the error is another.
>> I increase the time of silence to 7 instead of 3.
>> it seems to be that in this time that session.streamFile is executed (3sec.
>> audio file) , the next instruction session.recordFile is executed, because
>> the first 5 seconds of audio files in the second run are silence.
>> I have no answer about this control.
>> for the first my changes works for me, but with a little bit more waiting
>> time.
>> 
>> Daniel
>> Am 14.07.2011 um 15:26 schrieb Jason Moran:
>> 
>> One other thing to check - make sure you aren't having problems with
>> open file handles.  You might have to play around with issuing an
>> fd.close() at the appropriate time or else try incrementing the file
>> name (and other permutations) to ensure you aren't blocking yourself
>> from writing the same file.
>> 
>> -Jason
>> 
>> -----Original Message-----
>> From: Daniel Knoll [mailto:daniel at danielknoll.de]
>> Sent: Wednesday, July 13, 2011 6:28 PM
>> To: FreeSWITCH Users Help
>> Subject: Re: [Freeswitch-users] session.recordFile create empy wav in
>> whileloop
>> 
>> Hi Steve,
>> Thanx for helping me,
>> the call is established and the loop can be re-run and re-run. but the
>> new audio file that is created is empty.
>> i have the same issue if i use session.execute("record",
>> "/dev/shm/"+rd+".wav 10 150");
>> 
>> unfortunately there is no function to stop the record.
>> 
>> If you can help me I would be very thankful
>> 
>> Daniel
>> 
>> 
>> Am 13.07.2011 um 23:27 schrieb Steven Ayre:
>> 
>> I'd need to set up a testcase to confirm it, but I think it's probably
>> 
>> that recordFile blocks and doesn't return until it's finished
>> 
>> recording at the end of the call. As a result on the next loop
>> 
>> iteration there'll be no call so nothing to record.
>> 
>> -Steve
>> 
>> 
>> 
>> On 13 July 2011 22:17, Daniel Knoll <daniel at danielknoll.de> wrote:
>> 
>> Any Ideas for my problem?
>> 
>> The question is, why is the audio file empty if i re-run in while
>> 
>> loop?
>> 
>> Thanks
>> 
>> Daniel
>> 
>> 
>> Am 13.07.2011 um 11:24 schrieb Daniel Knoll:
>> 
>> Hi Steve, thanks for fast answer. The Channel is't hung up, because
>> 
>> I
>> 
>> stream in the same loop an Audio File
>> 
>> here is the code, the session.recordFile is executed in the second
>> 
>> run, because, the filesize is changing for the file at first run.
>> 
>> do {
>> 
>>      var rd = session.uuid;
>> 
>> session.streamFile("/dev/shm/freeswitch/sounds/conf-asrintro.wav", "");
>> 
>>      session.recordFile("/dev/shm/"+rd+".wav", "", "", 10, 500, 3);
>> 
>>              system("sox -v 1.7 /dev/shm/"+rd+".wav -r 16000
>> 
>> /dev/shm/"+rd+".flac");
>> 
>>      var fd = new File("|/usr/bin/googlespeech.sh
>> 
>> /dev/shm/"+rd+".flac");
>> 
>>      fd.open("read");
>> 
>>      var dtmf = fd.read("8");
>> 
>>      dtmf = dtmf.replace(/[^0-9]/g, '');
>> 
>>      console_log("notice", "DTMF: "+ dtmf +"\n");
>> 
>>      roomExists = checkRoom(dtmf);
>> 
>>      if(!roomExists){
>> 
>>              retry_count++;
>> 
>> session.streamFile("/dev/shm/freeswitch/sounds/conf-invalid.wav", "");
>> 
>>              var dtmf = "";
>> 
>>      }
>> 
>> } while(!roomExists && retry_count < 5);
>> 
>> 
>> I googled at this and found some guys he has also the same problem
>> 
>> http://asterisk.voicemeup.com/viewtopic.php?p=62294&sid=8360229099e219df
>> 50bbb016cd43cbfd
>> 
>> Can you help me ?
>> 
>> Thanx Daniel
>> 
>> 
>> 
>> 
>> 
>> 2011/7/13, Steven Ayre <steveayre at gmail.com>:
>> 
>> Are you able to share the code?
>> 
>> Are you checking session.ready in the while loop's condition? Might
>> 
>> the
>> 
>> channel be hung up when it reaches the 2nd recordFile?
>> 
>> -Steve
>> 
>> 
>> On 13 July 2011 10:01, Daniel Knoll <daniel at danielknoll.de> wrote:
>> 
>> Hey Guys,
>> 
>> i have a strange Problem with session.recordFile in a while loop
>> 
>> and i
>> 
>> don't know how to solve it.
>> 
>> The first run in the loop is absolutly ok, session.recordFile is
>> 
>> creating a good clean wavefile.
>> 
>> but in the second, third ..  run, every wav file has a size of
>> 
>> 47724
>> 
>> byte and no audio content.
>> 
>> Please help me, because it is an urgent case.
>> 
>> Thankx for getting help.
>> 
>> Daniel
>> 
>> _______________________________________________
>> 
>> 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
>> 
>> 
>> 
>> 
>> --
>> 
>> Daniel Knoll
>> 
>> Liberdastr.. 9
>> 
>> 12047 Berlin
>> 
>> fon +49 (0)179 20 16 50 8
>> 
>> mail daniel at danielknoll.de
>> 
>> web www.danielknoll.de
>> 
>> 
>> _______________________________________________
>> 
>> 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, 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, 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, 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
>> 
>> 
> 
> 
> 
> -- 
> Anthony Minessale II
> 
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
> Twitter: http://twitter.com/FreeSWITCH_wire
> 
> AIM: anthm
> MSN:anthony_minessale at hotmail.com
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
> IRC: irc.freenode.net #freeswitch
> 
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org
> googletalk:conf+888 at conference.freeswitch.org
> pstn:+19193869900
> 
> _______________________________________________
> 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




More information about the FreeSWITCH-users mailing list