in reply to How can I reduce the time taken by wav file to save in /tmp folder

From your code, I'm a bit unclear as to which part actually takes too long.

Is it this line?

my $response = $ua->get("http://127.0.0.1:8000/speech_to_text/?file_pa +th=$tmpname.wav");

... or is there anything else?

I'm not sure how AGI programs work. Maybe you can only send one action per invocation, so you have then to find out when recording the file ended?

  • Comment on Re: How can I reduce the time taken by wav file to save in /tmp folder
  • Download Code

Replies are listed 'Best First'.
Re^2: How can I reduce the time taken by wav file to save in /tmp folder
by srikanth (Initiate) on Dec 04, 2021 at 08:52 UTC
    print "RECORD FILE $tmpname wav \"$intkey\" \"$abs_timeout\" $beep \"$silence\"\n"; this is the line which is taking time to create file

      I would think this takes time to create because it is writing the file while recording. If you record 60 seconds, the file will take 60 seconds to create.

      Do you expect something different?

        if that is the case then it should be same for every file it creates but it is not happening in that way. For every 20 files (approximately) it creates, 1 file it is taking time to create.
      That just looks like a print statement to me. I don't see anything that should "take time". STDOUT is buffered. Buffering can cause a delay in writing to the screen and make it look like something took a long time when in fact it didn't. Add this line: $|=1; at the top of your Perl code. That will turn off buffering.