Permalink
Browse files

correct ounting

  • Loading branch information...
1 parent 619dbfb commit 3d9599bea93bc882e58905cd88645af0432ac297 @taf2 committed Apr 5, 2011
Showing with 25 additions and 6 deletions.
  1. 0 bin/speech2text
  2. +24 −5 lib/speech/audio_inspector.rb
  3. +1 −1 lib/speech/version.rb
View
0 bin/speech2text 100644 → 100755
File mode changed.
View
29 lib/speech/audio_inspector.rb
@@ -19,7 +19,7 @@ def to_s
end
def to_f
- self.total_seconds
+ (self.hours.to_i * 3600) + (self.minutes.to_i * 60) + self.seconds.to_f
end
def self.from_seconds(seconds)
@@ -39,7 +39,8 @@ def self.from_seconds(seconds)
end
def +(b)
- self.to_f + b.to_f
+ total = self.to_f + b.to_f
+# puts "total: #{self.to_f} + #{b.to_f} = #{total.inspect}"
Duration.from_seconds(self.to_f + b.to_f)
end
@@ -61,17 +62,35 @@ def test_add_duration
a = Speech::AudioInspector::Duration.new("00:00:12.12")
b = Speech::AudioInspector::Duration.new("00:00:02.00")
- assert "00:00:14.12", (a + b).to_s
+ assert_equal "00:00:14:12", (a + b).to_s
a = Speech::AudioInspector::Duration.new("00:10:12.12")
b = Speech::AudioInspector::Duration.new("08:00:02.00")
- assert "08:10:14:12", (a + b).to_s
+ assert_equal "08:10:14:12", (a + b).to_s
a = Speech::AudioInspector::Duration.new("02:10:12.12")
b = Speech::AudioInspector::Duration.new("08:55:02.10")
- assert "11:05:14:22", (a + b).to_s
+ assert_equal "11:05:14:22", (a + b).to_s
+
+ a = Speech::AudioInspector::Duration.new("00:00:12.12")
+ b = Speech::AudioInspector::Duration.new("00:00:02.00")
+
+ a = a + b
+ assert_equal "00:00:14:12", a.to_s
+ puts a.inspect
+
+ a = a + b
+ puts a.inspect
+
+ assert_equal "00:00:16:12", a.to_s
+
+ a = a + b
+ puts a.to_s
+ assert_equal "00:00:18:12", a.to_s
+ puts a.to_s
end
+
end
end
View
2 lib/speech/version.rb
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
module Speech
class Info
- VERSION='0.3.3'
+ VERSION='0.3.4'
end
end

0 comments on commit 3d9599b

Please sign in to comment.