audio_hero 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bb1e0dddd042652fedc3c8afa209a38782599ad
4
- data.tar.gz: e240c77cdc42674a5c16beb480714a5078315577
3
+ metadata.gz: 0a863dd10c8f50517fca19149c8e578be91f3aa0
4
+ data.tar.gz: 12102137628f626cc726002de63145fa6d662dcd
5
5
  SHA512:
6
- metadata.gz: b04e7418655b10d21e43444104c3d4d0c8610d30022203cd95b7fc310ea7e0d7bba1b92a5267607dd32c8662987274ba59c5b9de69d97b2fa220fe85f9218338
7
- data.tar.gz: 9fe578470e0bf6c95e6cc220a89e13b7615e277b87a6c107126f04be2b83e91ddf7a1c742e77c0f67f81f003187df3d3e73c1b1a33e65821997aa87ae12f9fb9
6
+ metadata.gz: d59a8b243e36b9d68fe78c20ddd9cccc92da847030bc4e65640aea63cc2cd4c602ba24eac92705895a88a8180a64135fe38af806dd5fe4cfff3a8a1794424fd8
7
+ data.tar.gz: 576a9f8571b1f43b51b60d1244f24c3e3fa36d57aa9bf5a810326c933772cc663fc81da3eb2ed5fe196f7c0867d9a29d7e1390a7d95a27b37cd338832698bb5e
data/README.md CHANGED
@@ -72,6 +72,7 @@ Options(hash):
72
72
  * silence_level (default to 0.03%)
73
73
  * input_format (default to "mp3")
74
74
  * output_format (default to "wav")
75
+ * output_filename (base filename, default to "out". If using custom version of SOX, use "%,1c" for starttime and use "%1,1c-%1,1d" for starttime-endtime as filename)
75
76
  * file2 (path to second audio file, I use this to split both channels of an audio file at one go, require a modified sox that will not overwrite file1's output. Eg. my modified sox output [milliseconds].wav instead of 001.wav)
76
77
  * gc (no default, set to "true" to auto close! input file)
77
78
 
@@ -86,6 +87,17 @@ Options(hash):
86
87
  * input_format (default to "mp3")
87
88
  * gc (no default, set to "true" to auto close! input file)
88
89
 
90
+ ###Extract Features
91
+ Extract audio features using custom version of Yaafe script.
92
+
93
+ ```ruby
94
+ features = AudioHero::Sox.new(file).extract_features({sample_rate: "8000"})
95
+ # {"feature1"=>0.34,"feature2"=>2.25}
96
+ ```
97
+ Options(hash):
98
+ * sample_rate (default to "8000")
99
+ * gc (no default, set to "true" to auto close! input file)
100
+
89
101
  ###Custom Command
90
102
 
91
103
  Run any sox command with this method.
Binary file
Binary file
Binary file
data/audio_hero.gemspec CHANGED
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "rspec"
32
32
  spec.add_dependency("cocaine", "~> 0.5")
33
+ spec.add_dependency("msgpack", "~> 1.0")
33
34
  end
@@ -1,3 +1,3 @@
1
1
  module AudioHero
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/audio_hero.rb CHANGED
@@ -80,17 +80,19 @@ module AudioHero
80
80
  # Returns an array of the full path of the splitted files, can split two input files at one go using {file2: file} option.
81
81
  # Remember its good practice to remove the temp directory after use.
82
82
  # FileUtils.remove_entry tempdir
83
+
83
84
  def split_by_silence(options={})
84
85
  silence_duration = options[:silence_duration] || "0.5"
85
86
  silence_level = options[:silence_level] || "0.03"
86
87
  effect = "silence 1 #{silence_duration} #{silence_level}% 1 #{silence_duration} #{silence_level}% : newfile : restart"
87
88
  input_format = options[:input_format] ? options[:input_format] : "mp3"
88
89
  output_format = options[:output_format]
90
+ output_filename = options[:output_filename] || "out"
89
91
  file2 = options[:file2]
90
92
  # Default to wav
91
93
  dir = Dir.mktmpdir
92
94
  format = output_format ? ".#{output_format}" : ".wav"
93
- dst = "#{dir}/out#{format}"
95
+ dst = "#{dir}/#{output_filename}#{format}"
94
96
 
95
97
  src = @file
96
98
  src2 = file2
@@ -129,6 +131,23 @@ module AudioHero
129
131
  parse_stats(success)
130
132
  end
131
133
 
134
+ # Requires custom version of yaafe
135
+ def extract_features(options={})
136
+ src = @file
137
+ rate = options[:sample_rate] || "8000"
138
+ begin
139
+ parameters = []
140
+ parameters << "-r #{rate}"
141
+ parameters << ":source"
142
+ parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
143
+ success = Cocaine::CommandLine.new("yaafehero", parameters).run(:source => File.expand_path(src.path))
144
+ rescue => e
145
+ raise AudioHeroError, "These was an issue getting stats from #{@basename}"
146
+ end
147
+ src.close! if options[:gc] == "true"
148
+ MessagePack.unpack(success)
149
+ end
150
+
132
151
  def command(options={})
133
152
  global = options[:global_options]
134
153
  input_options = options[:input_options]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_hero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - litenup
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
11
+ date: 2016-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: msgpack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
69
83
  description:
70
84
  email:
71
85
  - alanhsu@mycallhero.com
@@ -81,6 +95,9 @@ files:
81
95
  - LICENSE.txt
82
96
  - README.md
83
97
  - Rakefile
98
+ - audio_hero-0.1.0.gem
99
+ - audio_hero-0.1.1.gem
100
+ - audio_hero-0.1.2.gem
84
101
  - audio_hero.gemspec
85
102
  - bin/console
86
103
  - bin/setup