Introduction
Introduction Statistics Contact Development Disclaimer Help
export_audio.rb - warvox - VoIP based wardialing tool, forked from rapid7/warvo…
git clone git://jay.scot/warvox
Log
Files
Refs
README
---
export_audio.rb (2061B)
---
1 #!/usr/bin/env ruby
2 ###################
3
4 #
5 # Load the library path
6 #
7 base = __FILE__
8 while File.symlink?(base)
9 base = File.expand_path(File.readlink(base), File.dirname(base))
10 end
11 $:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
12
13 require 'warvox'
14 require 'fileutils'
15 require 'yaml'
16
17 ENV['RAILS_ENV'] ||= 'production'
18 $:.unshift(File.join(File.expand_path(File.dirname(base)), '..'))
19
20 def usage
21 $stderr.puts "Usage: #{$0} [Output Dir] [Project ID] <Line Type>"
22 exit
23 end
24
25 #
26 # Script
27 #
28
29 output = ARGV.shift
30 project_id = ARGV.shift
31 line_type = ARGV.shift
32
33 if(output and output == "-h") or (! output)
34 usage()
35 end
36
37 require 'config/boot'
38 require 'config/environment'
39
40 if project_id.to_i == 0
41 $stderr.puts "Listing all projects"
42 $stderr.puts "===================="
43 Project.all.each do |j|
44 puts "#{j.id}\t#{j.name}\t#{j.created_at}"
45 end
46 exit
47 end
48
49 FileUtils.mkdir_p(output)
50
51 begin
52 cond = { project_id: project_id.to_i, answered: true, busy: false }
53 if line_type
54 cond[:line_type] = line_type.downcase
55 end
56
57 Call.where(cond).order(number: :asc).each do |r|
58 m = r.media
59 if m and m.audio
60
61 ::File.open(File.join(output, "#{r.number}.wav"), "wb") do |fd|
62 if m.audio[0,4].to_s == "RIFF"
63 fd.write(m.audio)
64 else
65 # Add a WAV header to the sample
66 raw = WarVOX::Audio::Raw.new(m.audio)
67 fd.write(raw.to_wav)
68 end
69 end
70
71 ::File.open(File.join(output, "#{r.number}.yml"), "wb") do |fd|
72 fd.write(r.to_yaml)
73 end
74
75 if m.mp3
76 ::File.open(File.join(output, "#{r.number}.mp3"), "wb") do |fd|
77 fd.write(m.mp3)
78 end
79 end
80
81 if m.png_big
82 ::File.open(File.join(output, "#{r.number}_wave.png"), "wb") do …
83 fd.write(m.png_big)
84 end
85 end
86
87 if m.png_big_freq
88 ::File.open(File.join(output, "#{r.number}_freq.png"), "wb") do …
89 fd.write(m.png_big_freq)
90 end
91 end
92
93 $stderr.puts "[*] Exported #{r.number}..."
94
95 end
96 end
97 end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.