Class: Google::Cloud::Speech::Result
- Inherits:
-
Object
- Object
- Google::Cloud::Speech::Result
- Defined in:
- lib/google/cloud/speech/result.rb
Overview
# Result
A speech recognition result corresponding to a portion of the audio.
See Project#recognize and Job#results.
Defined Under Namespace
Classes: Alternative
Instance Attribute Summary collapse
-
#alternatives ⇒ Array<Result::Alternative>
readonly
Additional recognition hypotheses (up to the value specified in ‘max_alternatives`).
-
#confidence ⇒ Float
readonly
The confidence estimate between 0.0 and 1.0.
-
#transcript ⇒ String
readonly
Transcript text representing the words that the user spoke.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(transcript, confidence, alternatives = []) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(transcript, confidence, alternatives = []) ⇒ Result
Returns a new instance of Result.
61 62 63 64 65 |
# File 'lib/google/cloud/speech/result.rb', line 61 def initialize transcript, confidence, alternatives = [] @transcript = transcript @confidence = confidence @alternatives = alternatives end |
Instance Attribute Details
#alternatives ⇒ Array<Result::Alternative> (readonly)
Additional recognition hypotheses (up to the value specified in ‘max_alternatives`). The server may return fewer than `max_alternatives`.
56 57 58 |
# File 'lib/google/cloud/speech/result.rb', line 56 def alternatives @alternatives end |
#confidence ⇒ Float (readonly)
The confidence estimate between 0.0 and 1.0. A higher number means the system is more confident that the recognition is correct. This field is typically provided only for the top hypothesis. A value of 0.0 is a sentinel value indicating confidence was not set.
56 57 58 |
# File 'lib/google/cloud/speech/result.rb', line 56 def confidence @confidence end |
#transcript ⇒ String (readonly)
Transcript text representing the words that the user spoke.
56 57 58 |
# File 'lib/google/cloud/speech/result.rb', line 56 def transcript @transcript end |
Class Method Details
.from_grpc(grpc) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/google/cloud/speech/result.rb', line 69 def self.from_grpc grpc head, *tail = *grpc.alternatives return nil if head.nil? alternatives = tail.map do |alt| Alternative.new alt.transcript, alt.confidence end new head.transcript, head.confidence, alternatives end |