Class: Google::Cloud::Speech::Result::Alternative

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/speech/result.rb

Overview

Result::Alternative

A speech recognition result corresponding to a portion of the audio.

Examples:

require "google/cloud/speech"

speech = Google::Cloud::Speech.new

audio = speech.audio "path/to/audio.raw",
                     encoding: :raw, sample_rate: 16000
results = audio.recognize

result = results.first
result.transcript #=> "how old is the Brooklyn Bridge"
result.confidence #=> 0.9826789498329163
alternative = result.alternatives.first
alternative.transcript #=> "how old is the Brooklyn brim"
alternative.confidence #=> 0.22030000388622284

Instance Attribute Summary collapse

Instance Attribute Details

#confidenceFloat (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.

Returns:

  • (Float)

    the current value of confidence



107
108
109
# File 'lib/google/cloud/speech/result.rb', line 107

def confidence
  @confidence
end

#transcriptString (readonly)

Transcript text representing the words that the user spoke.

Returns:

  • (String)

    the current value of transcript



107
108
109
# File 'lib/google/cloud/speech/result.rb', line 107

def transcript
  @transcript
end