google_speech 0.1.5 → 0.1.6

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2U2ZDQwNGFhYzhmNjIxZjkzYmRmYjM4ZTI1ZDE3MzY3MzVjYWUxMw==
4
+ MDVkYmNiZGJiNGY2Y2Y2NmY2YjAwZThhNGMwMGY5MzM4MzE5MTAzMQ==
5
5
  data.tar.gz: !binary |-
6
- NGZmNWZlOTEyOTI4MzNkMDRmZTYzNjJhZmNlYTYyMWU1NDllNmQ4Ng==
6
+ YWIwYzg5YTM0YmYwNjcwMThjYWNlMTExZjQ1NWM1ODcwYmNjZjljYQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjdhNTE3NDZhMjQ3ZjE5MTg0YmZhMDM4MGJmNzRjY2RjNDVlY2VkNDk1ZDA1
10
- OTBhYzA2NTU4MTgyN2JlNWZlMzI1NmI2NTk0ZmNjMGM2NTk3YjdkMTk0NzVh
11
- Yzg3NTUxNWZhNDcwYmI2MTdkNmYxZDUzMmQ5OGFiOGI5ZjdlNWI=
9
+ YzZlMzVkNzFkZTNmODc1ZTdhYTJlYTA0ZWExOGFiMDliNWJhYmRmZDhiY2Rj
10
+ ODgwODJkN2UyY2VmZmZjNTJiY2Y4YjFhYzAxY2ZkYmQ1ZmI1YjMyNWQ1MDNi
11
+ OWQ2ODVjNjQwYWQ5ODY3YTMxYTg4YjlhYjY2YmVlMDEwMmUwODM=
12
12
  data.tar.gz: !binary |-
13
- ZGUyYzgzNmMzOWQ1ZGQwMGJiMDgzYjNiYzM4YTJhMTEzOGM3NTlhYmFkMGJm
14
- MzJjZmZmMTcxYjdiNzg4YTk0NDNiNGYzYTlmZmExZTllZGFkYjA5ZTExOTY2
15
- MTUxYzdkOWQ1NGViZDYxM2RjODMwYzZiYzNmZDNjYjFhYzI3M2M=
13
+ ZDIwMWY5OWNjNmE3ZDIxYmIxOWRlMjBlYWIwMDk3YTdkZjkwMDU3ZDA3MmU3
14
+ ZDQ2NWZkMDhkZTViZjRhYTBiMWFiMDYxZDk2ZWZkMWU1ZTAxZjg4ZTg0YjMy
15
+ MDhhZDk2YWRmOGEzOTdkOTI0YzRmMDFjMDYxZjZiZWIyYjJhNjg=
@@ -43,10 +43,14 @@ module GoogleSpeech
43
43
 
44
44
  def extract_result(transcripts)
45
45
  results = transcripts.map{|t| result_from_transcript(t)}.compact
46
- {
47
- :text => results.collect {|t| t[:text] }.join(' '),
48
- :confidence => results.inject(0.0) {|s, t| s + t[:confidence].to_f } / results.size
49
- }
46
+
47
+ return {:text => '', :confidence => 0} if results.size == 0
48
+
49
+ t = results.collect {|t| t[:text] }.join(' ')
50
+ c = results.inject(0.0) {|s, t| s.to_f + t[:confidence].to_f } / results.size.to_f
51
+ c = 0 if c.nan? || c.infinite?
52
+
53
+ { :text => t, :confidence => c }
50
54
  end
51
55
 
52
56
  def result_from_transcript(transcript)
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module GoogleSpeech
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_speech
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kuklewicz