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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0721ddf5fe7fa3de9caad8c076c0c736629eace
4
- data.tar.gz: c6846c36da7ce0ae635c06bff9d780356b6a096c
3
+ metadata.gz: f4b996987545fa56605083bf12a723494c86f0b3
4
+ data.tar.gz: 50be06fc5b29c24131d7377e2ff1700863e6f5d8
5
5
  SHA512:
6
- metadata.gz: 86187c87e472e88057db1acf71bcb0e441ff3c8d63e4896a3152ed6c0c4a8ef32ef954d4eb9a31c171738d2bfdb0638fd0cc3be8561dd33c23cf80bd3e4f0c0f
7
- data.tar.gz: ee612e9298816da4e971587f8373d59792d467d4cb78373c4dd819794754011513879c1604e5a748c62d3a576e9812bfe51c8d41f73c8e7843cd75a69461716c
6
+ metadata.gz: 58171ba7cf9dec81f8bf0a02230c6b9a8f4094becf374dac701b5100672f5d330e4096edb01e7f161ccd89689961927c1c7e4af3c7fd6f6ccd555156511e7f0d
7
+ data.tar.gz: 5aa28748969ddf57632478aafe52ff8f4f6d93b31a1900b57f2aaad1366dbe8a1d98b9c985561b5af803ecfc9753da9ef384a144e961e463b40e9ac9e43058af
@@ -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"
@@ -15,9 +15,18 @@ class AudioTrimmer
15
15
  end
16
16
  end
17
17
 
18
- def trim(start: 0, finish: get_length(@input), output: @input)
19
- unless File.exist?(@input) or File.exist?(output) then raise "bad filepath" end
20
- `sox #{@input} #{output} trim #{start} =#{finish}`
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.3
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-14 00:00:00.000000000 Z
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 for most filetypes
45
+ summary: simple audio trimmer toolkit in ruby
44
46
  test_files: []