audio-trimmer 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/audio_trimmer.rb +7 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0721ddf5fe7fa3de9caad8c076c0c736629eace
|
4
|
+
data.tar.gz: c6846c36da7ce0ae635c06bff9d780356b6a096c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86187c87e472e88057db1acf71bcb0e441ff3c8d63e4896a3152ed6c0c4a8ef32ef954d4eb9a31c171738d2bfdb0638fd0cc3be8561dd33c23cf80bd3e4f0c0f
|
7
|
+
data.tar.gz: ee612e9298816da4e971587f8373d59792d467d4cb78373c4dd819794754011513879c1604e5a748c62d3a576e9812bfe51c8d41f73c8e7843cd75a69461716c
|
data/lib/audio_trimmer.rb
CHANGED
@@ -6,16 +6,19 @@ class AudioTrimmer
|
|
6
6
|
attr_accessor :input
|
7
7
|
|
8
8
|
def initialize(params = {})
|
9
|
-
|
9
|
+
input = params.fetch(:input, "")
|
10
10
|
input_length = 0
|
11
|
-
if
|
11
|
+
if input.empty?
|
12
12
|
raise "please specify input filepath"
|
13
|
+
else
|
14
|
+
@input = File.expand_path(input)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
18
|
def trim(start: 0, finish: get_length(@input), output: @input)
|
17
|
-
unless File.exist?(
|
18
|
-
`sox #{@input} #{output} trim #{start}
|
19
|
+
unless File.exist?(@input) or File.exist?(output) then raise "bad filepath" end
|
20
|
+
`sox #{@input} #{output} trim #{start} =#{finish}`
|
21
|
+
return "trim success"
|
19
22
|
end
|
20
23
|
|
21
24
|
def get_length file_path
|