audio-trimmer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/audio_trimmer +28 -0
- data/lib/audio_trimmer.rb +12 -3
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4b996987545fa56605083bf12a723494c86f0b3
|
4
|
+
data.tar.gz: 50be06fc5b29c24131d7377e2ff1700863e6f5d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58171ba7cf9dec81f8bf0a02230c6b9a8f4094becf374dac701b5100672f5d330e4096edb01e7f161ccd89689961927c1c7e4af3c7fd6f6ccd555156511e7f0d
|
7
|
+
data.tar.gz: 5aa28748969ddf57632478aafe52ff8f4f6d93b31a1900b57f2aaad1366dbe8a1d98b9c985561b5af803ecfc9753da9ef384a144e961e463b40e9ac9e43058af
|
data/bin/audio_trimmer
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# example command: audio_trimmer 'test.wav' -s=0 -f=30 -o='test_output.wav'
|
4
|
+
|
5
|
+
require 'audio_trimmer'
|
6
|
+
|
7
|
+
unless ARGV[0].nil?
|
8
|
+
input_file = File.expand_path(ARGV[0])
|
9
|
+
else
|
10
|
+
raise "specify input file, e.g. 'audio_trimmer [input_file] -s [start trim] -f [finish trim]'"
|
11
|
+
end
|
12
|
+
|
13
|
+
trimmer = nil
|
14
|
+
if File.exists?(input_file)
|
15
|
+
trimmer = AudioTrimmer.new input:ARGV[0]
|
16
|
+
else
|
17
|
+
raise "bad input file, put correct input file as first arg e.g. 'audio_trimmer [input_file] -s [start trim] -f [finish trim]'"
|
18
|
+
end
|
19
|
+
|
20
|
+
args = Hash[ ARGV.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/) ]
|
21
|
+
|
22
|
+
unless args.key?('o')
|
23
|
+
trimmer.trim start:args['s'], finish:args['f']
|
24
|
+
else
|
25
|
+
trimmer.trim start:args['s'], finish:args['f'], output:args['o']
|
26
|
+
end
|
27
|
+
|
28
|
+
puts "trim success"
|
data/lib/audio_trimmer.rb
CHANGED
@@ -15,9 +15,18 @@ class AudioTrimmer
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def trim(start: 0, finish: get_length(@input), output:
|
19
|
-
unless File.
|
20
|
-
|
18
|
+
def trim(start: 0, finish: get_length(@input), output: "")
|
19
|
+
unless File.exists?(@input) or File.exists?(output) then raise "bad filepath" end
|
20
|
+
if output.empty? or File.expand_path(output) == @input
|
21
|
+
out_arr = @input.split('.')
|
22
|
+
out_arr[out_arr.length-2] += "_out"
|
23
|
+
output = out_arr.join(".")
|
24
|
+
`sox #{@input} #{output} trim #{start} =#{finish}`
|
25
|
+
`mv #{output} #{@input}`
|
26
|
+
else
|
27
|
+
output = File.expand_path(output)
|
28
|
+
`sox #{@input} #{output} trim #{start} =#{finish}`
|
29
|
+
end
|
21
30
|
return "trim success"
|
22
31
|
end
|
23
32
|
|
metadata
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: audio-trimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brigden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: audio trimmer powered by sox
|
14
14
|
email: rbrigden@cmu.edu
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- audio_trimmer
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- bin/audio_trimmer
|
19
21
|
- lib/audio_trimmer.rb
|
20
22
|
homepage: https://github.com/rbrigden/audio-trimmer-ruby
|
21
23
|
licenses:
|
@@ -40,5 +42,5 @@ rubyforge_project:
|
|
40
42
|
rubygems_version: 2.4.5
|
41
43
|
signing_key:
|
42
44
|
specification_version: 4
|
43
|
-
summary: audio trimmer
|
45
|
+
summary: simple audio trimmer toolkit in ruby
|
44
46
|
test_files: []
|