speech2text 0.3.2 → 0.3.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.
- data/lib/speech/audio_inspector.rb +36 -2
- data/lib/speech/version.rb +1 -1
- data/test/audio_to_text_test.rb +9 -6
- metadata +6 -6
@@ -23,16 +23,26 @@ module Speech
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.from_seconds(seconds)
|
26
|
+
# puts "total seconds: #{seconds.inspect}"
|
26
27
|
duration = Duration.new("00:00:00.00")
|
27
28
|
duration.hours = (seconds.to_i / 3600).to_i
|
28
|
-
|
29
|
-
duration.
|
29
|
+
# puts "hours: #{duration.hours.inspect}"
|
30
|
+
duration.minutes = ((seconds.to_i - (duration.hours*3600)) / 60).to_i
|
31
|
+
# puts "minutes: #{duration.minutes.inspect}"
|
32
|
+
secs = (seconds - (duration.minutes*60) - (duration.hours*3600))
|
33
|
+
duration.seconds = sprintf("%.2f", secs)
|
34
|
+
# puts "seconds: #{duration.seconds.inspect}"
|
30
35
|
duration.hours = duration.hours.to_s
|
31
36
|
duration.minutes = duration.minutes.to_s
|
32
37
|
|
33
38
|
duration
|
34
39
|
end
|
35
40
|
|
41
|
+
def +(b)
|
42
|
+
self.to_f + b.to_f
|
43
|
+
Duration.from_seconds(self.to_f + b.to_f)
|
44
|
+
end
|
45
|
+
|
36
46
|
end
|
37
47
|
|
38
48
|
def initialize(file)
|
@@ -41,3 +51,27 @@ module Speech
|
|
41
51
|
|
42
52
|
end
|
43
53
|
end
|
54
|
+
|
55
|
+
if $0 == __FILE__
|
56
|
+
require 'test/unit'
|
57
|
+
|
58
|
+
class QuickTest < Test::Unit::TestCase
|
59
|
+
|
60
|
+
def test_add_duration
|
61
|
+
a = Speech::AudioInspector::Duration.new("00:00:12.12")
|
62
|
+
b = Speech::AudioInspector::Duration.new("00:00:02.00")
|
63
|
+
|
64
|
+
assert "00:00:14.12", (a + b).to_s
|
65
|
+
|
66
|
+
a = Speech::AudioInspector::Duration.new("00:10:12.12")
|
67
|
+
b = Speech::AudioInspector::Duration.new("08:00:02.00")
|
68
|
+
|
69
|
+
assert "08:10:14:12", (a + b).to_s
|
70
|
+
|
71
|
+
a = Speech::AudioInspector::Duration.new("02:10:12.12")
|
72
|
+
b = Speech::AudioInspector::Duration.new("08:55:02.10")
|
73
|
+
|
74
|
+
assert "11:05:14:22", (a + b).to_s
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/speech/version.rb
CHANGED
data/test/audio_to_text_test.rb
CHANGED
@@ -8,12 +8,15 @@ class SpeechAudioToTextTest < Test::Unit::TestCase
|
|
8
8
|
audio = Speech::AudioToText.new("samples/i-like-pickles.wav")
|
9
9
|
captured_json = audio.to_text
|
10
10
|
assert captured_json
|
11
|
-
assert captured_json.key?("
|
12
|
-
assert !captured_json['
|
13
|
-
|
14
|
-
|
15
|
-
assert captured_json
|
16
|
-
|
11
|
+
assert captured_json.key?("hypotheses")
|
12
|
+
assert !captured_json['hypotheses'].empty?
|
13
|
+
assert captured_json.keys.include?('status')
|
14
|
+
assert captured_json.keys.include?('id')
|
15
|
+
assert captured_json.keys.include?('hypotheses')
|
16
|
+
|
17
|
+
assert_equal "I like pickles", captured_json['hypotheses'].first.first
|
18
|
+
assert captured_json['hypotheses'].first.last > 0.9
|
19
|
+
# {"hypotheses"=>[["I like pickles", 0.92731786]]}
|
17
20
|
# puts captured_json.inspect
|
18
21
|
ensure
|
19
22
|
audio.clean
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speech2text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-04-
|
12
|
+
date: 2011-04-05 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: curb
|
17
|
-
requirement: &
|
17
|
+
requirement: &2163558380 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2163558380
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: json
|
28
|
-
requirement: &
|
28
|
+
requirement: &2163557840 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2163557840
|
37
37
|
description: Super powers of Google wrapped in a nice Ruby interface
|
38
38
|
email: todd.fisher@gmail.com
|
39
39
|
executables:
|