Call hangup when copy recorded audio file from one location to another using fileutils

classic Classic list List threaded Threaded
4 messages Options
dev
Reply | Threaded
Open this post in threaded view
|

Call hangup when copy recorded audio file from one location to another using fileutils

dev
I am using asterisk adhearsion in my system. there are recorded file and needs to move to another location.  I use following script to do that. 

def run
  play "file://#{AUDIO_PATH}/Record_your_queries_Msg_new.wav"
  @filename=record_your_message
  transfer_recorded_file
  play
"file://#{AUDIO_PATH}/Concluding_Msg.wav"
  hangup
end

def record_your_message
  record_result = record :start_beep => true, :max_duration => 180, :interruptible => '#'
 
record_result.source_uri.to_s.chomp+'.wav'
end

def transfer_recorded_file
  FileUtils.makedirs('../web/static/audio/supports') unless directory_exists?('../web/static/audio/supports')
 
FileUtils.copy("/var/punchblock/record/#{@filename}","../web/static/audio/supports/#{@filename}")
end

def directory_exists?(directory)
 
File.directory?(directory)
end

but call hangup during file transfer and gives error message.

 ERROR Adhearsion::Call: 2c2410e7-b961-473f-a6de-3e7abe0ba84a@: <Errno::ENOENT> No such file or directory @ rb_sysopen - /var/punchblock/record/dccc51e8-b3a8-46e7-92bd-8579ef9a3c33.wav
/usr/local/lib/ruby/2.1.0/fileutils.rb:1401:in `initialize'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1401:in `open'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1401:in `copy_file'
/usr/local/lib/ruby/2.1.0/fileutils.rb:483:in `copy_file'
/usr/local/lib/ruby/2.1.0/fileutils.rb:400:in `block in cp'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1579:in `block in fu_each_src_dest'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1595:in `fu_each_src_dest0'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1577:in `fu_each_src_dest'
/usr/local/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
/home/achyut/connect/voiceinn-ncell/system/lib/support_call_controller.rb:91:in `transfer_recorded_file'
/home/achyut/connect/voiceinn-ncell/system/lib/support_call_controller.rb:11:in `run'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:119:in `execute!'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:94:in `block in exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `catch'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:98:in `exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:110:in `exec_with_callback'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:104:in `block (2 levels) in bg_exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/foundation/exception_handler.rb:5:in `catching_standard_errors'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:103:in `block in bg_exec'
/usr/local/lib/ruby/gems/2.1.0/gems/celluloid-0.15.2/lib/celluloid/thread_handle.rb:13:in `block in initialize'
/usr/local/lib/ruby/gems/2.1.0/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `call'
/usr/local/lib/ruby/gems/2.1.0/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `block in create'
/usr/local/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
/usr/local/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'


what is wrong with my code ? 

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Call hangup when copy recorded audio file from one location to another using fileutils

Ben Langfeld-2
A couple of things to look out for:

1. Asterisk reports recording completion *before* it mixes audio down to disk, so there is a brief window during which we may react to such an event before the recording is in fact present.
2. Is the file present on disk at all after a delay of a few seconds? You could verify this manually or inserting a sleep statement before you use the audio file.

If you find that the file is not actually present at the reported path even after a few seconds, then check that you have sox installed, which Asterisk uses for audio mixdown.

On 21 July 2015 at 05:47, dev <[hidden email]> wrote:
I am using asterisk adhearsion in my system. there are recorded file and needs to move to another location.  I use following script to do that. 

def run
  play "file://#{AUDIO_PATH}/Record_your_queries_Msg_new.wav"
  @filename=record_your_message
  transfer_recorded_file
  play
"file://#{AUDIO_PATH}/Concluding_Msg.wav"
  hangup
end

def record_your_message
  record_result = record :start_beep => true, :max_duration => 180, :interruptible => '#'
 
record_result.source_uri.to_s.chomp+'.wav'
end

def transfer_recorded_file
  FileUtils.makedirs('../web/static/audio/supports') unless directory_exists?('../web/static/audio/supports')
 
FileUtils.copy("/var/punchblock/record/#{@filename}","../web/static/audio/supports/#{@filename}")
end

def directory_exists?(directory)
 
File.directory?(directory)
end

but call hangup during file transfer and gives error message.

 ERROR Adhearsion::Call: 2c2410e7-b961-473f-a6de-3e7abe0ba84a@: <Errno::ENOENT> No such file or directory @ rb_sysopen - /var/punchblock/record/dccc51e8-b3a8-46e7-92bd-8579ef9a3c33.wav
/usr/local/lib/ruby/2.1.0/fileutils.rb:1401:in `initialize'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1401:in `open'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1401:in `copy_file'
/usr/local/lib/ruby/2.1.0/fileutils.rb:483:in `copy_file'
/usr/local/lib/ruby/2.1.0/fileutils.rb:400:in `block in cp'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1579:in `block in fu_each_src_dest'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1595:in `fu_each_src_dest0'
/usr/local/lib/ruby/2.1.0/fileutils.rb:1577:in `fu_each_src_dest'
/usr/local/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
/home/achyut/connect/voiceinn-ncell/system/lib/support_call_controller.rb:91:in `transfer_recorded_file'
/home/achyut/connect/voiceinn-ncell/system/lib/support_call_controller.rb:11:in `run'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:119:in `execute!'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:94:in `block in exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `catch'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:98:in `exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:110:in `exec_with_callback'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:104:in `block (2 levels) in bg_exec'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/foundation/exception_handler.rb:5:in `catching_standard_errors'
/usr/local/lib/ruby/gems/2.1.0/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:103:in `block in bg_exec'
/usr/local/lib/ruby/gems/2.1.0/gems/celluloid-0.15.2/lib/celluloid/thread_handle.rb:13:in `block in initialize'
/usr/local/lib/ruby/gems/2.1.0/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `call'
/usr/local/lib/ruby/gems/2.1.0/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `block in create'
/usr/local/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
/usr/local/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'


what is wrong with my code ? 

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
dev
Reply | Threaded
Open this post in threaded view
|

Re: Call hangup when copy recorded audio file from one location to another using fileutils

dev
In reply to this post by dev
1. Asterisk reports recording completion *before* it mixes audio down to disk, so there is a brief window during which we may react to such an event before the recording is in fact present.
2. Is the file present on disk at all after a delay of a few seconds? You could verify this manually or inserting a sleep statement before you use the audio file.

Thank you langfeld,
you are right. this is because of the delay in file present inside disk. and solved by 'sleep' in between record and transfer. 

def run
  play "file://#{AUDIO_PATH}/Record_your_queries_Msg_new.wav"
  @filename=record_your_message
  sleep
(1)
  transfer_recorded_file
  play
"file://#{AUDIO_PATH}/Concluding_Msg.wav"
  hangup
end

and i also encounter another problem of using relative path while moving file when adhearsion run in daemon.  i don't know  the reason why it give error and call hangup when adhearsion run in daemon. Thought it working in interactive mode 'ahn start'. it gives following permission denied error.

[2015-07-22 11:25:05.182] ERROR Adhearsion::Call: b7d2e8ba-6ac2-489b-9034-4c8c1659d5b8@: <Errno::EACCES> Permission denied @ dir_s_mkdir - ../web
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:252:in `mkdir'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:252:in `fu_mkdir'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:226:in `block (2 levels) in mkdir_p'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:224:in `reverse_each'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:224:in `block in mkdir_p'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:210:in `each'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:210:in `mkdir_p'
/home/younginnov/voiceinn-ncell/system/lib/admin_call_controller.rb:57:in `transfer_recorded_file'
/home/younginnov/voiceinn-ncell/system/lib/admin_call_controller.rb:45:in `record_broadcast_noticeboard'
/home/younginnov/voiceinn-ncell/system/lib/admin_call_controller.rb:10:in `run'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:119:in `execute!'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:94:in `block in exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `catch'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:98:in `exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:110:in `exec_with_callback'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:104:in `block (2 levels) in bg_exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/foundation/exception_handler.rb:5:in `catching_standard_errors'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:103:in `block in bg_exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/celluloid-0.15.2/lib/celluloid/thread_handle.rb:13:in `block in initialize'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `call'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `block in create'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'

this problem is solved just providing full path (absolute path) as follows. 

def transfer_recorded_file
  begin
    FileUtils.mkdir("#{full_path}/audio/supports") unless directory_exists?("#{full_path}/audio/supports")
    FileUtils.cp("/var/punchblock/record/#{@filename}","#{full_path}/audio/supports/#{@filename}")
  rescue Exception => e
    say "Error has occurred during audio file transfer."
  end
end



--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Call hangup when copy recorded audio file from one location to another using fileutils

Ben Langfeld-2
Note that you have `Adhearsion.root` available if you need it.

On 23 July 2015 at 05:25, dev <[hidden email]> wrote:
1. Asterisk reports recording completion *before* it mixes audio down to disk, so there is a brief window during which we may react to such an event before the recording is in fact present.
2. Is the file present on disk at all after a delay of a few seconds? You could verify this manually or inserting a sleep statement before you use the audio file.

Thank you langfeld,
you are right. this is because of the delay in file present inside disk. and solved by 'sleep' in between record and transfer. 

def run
  play "file://#{AUDIO_PATH}/Record_your_queries_Msg_new.wav"
  @filename=
record_your_message
  sleep
(1)
  transfer_recorded_file
  play
"file://#{AUDIO_PATH}/Concluding_Msg.wav"
  hangup
end

and i also encounter another problem of using relative path while moving file when adhearsion run in daemon.  i don't know  the reason why it give error and call hangup when adhearsion run in daemon. Thought it working in interactive mode 'ahn start'. it gives following permission denied error.

[2015-07-22 11:25:05.182] ERROR Adhearsion::Call: b7d2e8ba-6ac2-489b-9034-4c8c1659d5b8@: <Errno::EACCES> Permission denied @ dir_s_mkdir - ../web
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:252:in `mkdir'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:252:in `fu_mkdir'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:226:in `block (2 levels) in mkdir_p'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:224:in `reverse_each'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:224:in `block in mkdir_p'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:210:in `each'
/home/younginnov/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/fileutils.rb:210:in `mkdir_p'
/home/younginnov/voiceinn-ncell/system/lib/admin_call_controller.rb:57:in `transfer_recorded_file'
/home/younginnov/voiceinn-ncell/system/lib/admin_call_controller.rb:45:in `record_broadcast_noticeboard'
/home/younginnov/voiceinn-ncell/system/lib/admin_call_controller.rb:10:in `run'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:119:in `execute!'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:94:in `block in exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `catch'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:93:in `exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:98:in `exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:110:in `exec_with_callback'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:104:in `block (2 levels) in bg_exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/foundation/exception_handler.rb:5:in `catching_standard_errors'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/adhearsion-2.6.0/lib/adhearsion/call_controller.rb:103:in `block in bg_exec'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/celluloid-0.15.2/lib/celluloid/thread_handle.rb:13:in `block in initialize'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `call'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `block in create'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
/home/younginnov/.rvm/gems/ruby-2.2.1/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'

this problem is solved just providing full path (absolute path) as follows. 

def transfer_recorded_file
  begin
    FileUtils.mkdir("#{full_path}/audio/supports") unless directory_exists?("#{full_path}/audio/supports")
    FileUtils.cp("/var/punchblock/record/#{@filename}","#{full_path}/audio/supports/#{@filename}")
  rescue Exception => e
    say "Error has occurred during audio file transfer."
  end
end



--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.