Class: Google::Cloud::Speech::V2::StreamingRecognizeResponse

Inherits:
Object
  • Object
show all
Extended by:
Protobuf::MessageExts::ClassMethods
Includes:
Protobuf::MessageExts
Defined in:
proto_docs/google/cloud/speech/v2/cloud_speech.rb

Overview

StreamingRecognizeResponse is the only message returned to the client by StreamingRecognize. A series of zero or more StreamingRecognizeResponse messages are streamed back to the client. If there is no recognizable audio then no messages are streamed back to the client.

Here are some examples of StreamingRecognizeResponses that might be returned while processing audio:

  1. results { alternatives { transcript: "tube" } stability: 0.01 }

  2. results { alternatives { transcript: "to be a" } stability: 0.01 }

  3. results { alternatives { transcript: "to be" } stability: 0.9 } results { alternatives { transcript: " or not to be" } stability: 0.01 }

  4. results { alternatives { transcript: "to be or not to be" confidence: 0.92 } alternatives { transcript: "to bee or not to bee" } is_final: true }

  5. results { alternatives { transcript: " that's" } stability: 0.01 }

  6. results { alternatives { transcript: " that is" } stability: 0.9 } results { alternatives { transcript: " the question" } stability: 0.01 }

  7. results { alternatives { transcript: " that is the question" confidence: 0.98 } alternatives { transcript: " that was the question" } is_final: true }

Notes:

  • Only two of the above responses #4 and #7 contain final results; they are indicated by is_final: true. Concatenating these together generates the full transcript: "to be or not to be that is the question".

  • The others contain interim results. #3 and #6 contain two interim results: the first portion has a high stability and is less likely to change; the second portion has a low stability and is very likely to change. A UI designer might choose to show only high stability results.

  • The specific stability and confidence values shown above are only for illustrative purposes. Actual values may vary.

  • In each response, only one of these fields will be set: error, speech_event_type, or one or more (repeated) results.

Defined Under Namespace

Modules: SpeechEventType

Instance Attribute Summary collapse

Instance Attribute Details

#metadata::Google::Cloud::Speech::V2::RecognitionResponseMetadata

Returns Metadata about the recognition.

Returns:



1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'proto_docs/google/cloud/speech/v2/cloud_speech.rb', line 1199

class StreamingRecognizeResponse
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Indicates the type of speech event.
  module SpeechEventType
    # No speech event specified.
    SPEECH_EVENT_TYPE_UNSPECIFIED = 0

    # This event indicates that the server has detected the end of the user's
    # speech utterance and expects no additional speech. Therefore, the server
    # will not process additional audio and will close the gRPC bidirectional
    # stream. This event is only sent if there was a force cutoff due to
    # silence being detected early. This event is only available through the
    # `latest_short` {::Google::Cloud::Speech::V2::Recognizer#model model}.
    END_OF_SINGLE_UTTERANCE = 1

    # This event indicates that the server has detected the beginning of human
    # voice activity in the stream. This event can be returned multiple times
    # if speech starts and stops repeatedly throughout the stream. This event
    # is only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_BEGIN = 2

    # This event indicates that the server has detected the end of human voice
    # activity in the stream. This event can be returned multiple times if
    # speech starts and stops repeatedly throughout the stream. This event is
    # only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_END = 3
  end
end

#results::Array<::Google::Cloud::Speech::V2::StreamingRecognitionResult>

Returns This repeated list contains zero or more results that correspond to consecutive portions of the audio currently being processed. It contains zero or one is_final=true result (the newly settled portion), followed by zero or more is_final=false results (the interim results).

Returns:



1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'proto_docs/google/cloud/speech/v2/cloud_speech.rb', line 1199

class StreamingRecognizeResponse
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Indicates the type of speech event.
  module SpeechEventType
    # No speech event specified.
    SPEECH_EVENT_TYPE_UNSPECIFIED = 0

    # This event indicates that the server has detected the end of the user's
    # speech utterance and expects no additional speech. Therefore, the server
    # will not process additional audio and will close the gRPC bidirectional
    # stream. This event is only sent if there was a force cutoff due to
    # silence being detected early. This event is only available through the
    # `latest_short` {::Google::Cloud::Speech::V2::Recognizer#model model}.
    END_OF_SINGLE_UTTERANCE = 1

    # This event indicates that the server has detected the beginning of human
    # voice activity in the stream. This event can be returned multiple times
    # if speech starts and stops repeatedly throughout the stream. This event
    # is only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_BEGIN = 2

    # This event indicates that the server has detected the end of human voice
    # activity in the stream. This event can be returned multiple times if
    # speech starts and stops repeatedly throughout the stream. This event is
    # only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_END = 3
  end
end

#speech_event_offset::Google::Protobuf::Duration

Returns Time offset between the beginning of the audio and event emission.

Returns:



1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'proto_docs/google/cloud/speech/v2/cloud_speech.rb', line 1199

class StreamingRecognizeResponse
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Indicates the type of speech event.
  module SpeechEventType
    # No speech event specified.
    SPEECH_EVENT_TYPE_UNSPECIFIED = 0

    # This event indicates that the server has detected the end of the user's
    # speech utterance and expects no additional speech. Therefore, the server
    # will not process additional audio and will close the gRPC bidirectional
    # stream. This event is only sent if there was a force cutoff due to
    # silence being detected early. This event is only available through the
    # `latest_short` {::Google::Cloud::Speech::V2::Recognizer#model model}.
    END_OF_SINGLE_UTTERANCE = 1

    # This event indicates that the server has detected the beginning of human
    # voice activity in the stream. This event can be returned multiple times
    # if speech starts and stops repeatedly throughout the stream. This event
    # is only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_BEGIN = 2

    # This event indicates that the server has detected the end of human voice
    # activity in the stream. This event can be returned multiple times if
    # speech starts and stops repeatedly throughout the stream. This event is
    # only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_END = 3
  end
end

#speech_event_type::Google::Cloud::Speech::V2::StreamingRecognizeResponse::SpeechEventType

Returns Indicates the type of speech event.

Returns:



1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'proto_docs/google/cloud/speech/v2/cloud_speech.rb', line 1199

class StreamingRecognizeResponse
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Indicates the type of speech event.
  module SpeechEventType
    # No speech event specified.
    SPEECH_EVENT_TYPE_UNSPECIFIED = 0

    # This event indicates that the server has detected the end of the user's
    # speech utterance and expects no additional speech. Therefore, the server
    # will not process additional audio and will close the gRPC bidirectional
    # stream. This event is only sent if there was a force cutoff due to
    # silence being detected early. This event is only available through the
    # `latest_short` {::Google::Cloud::Speech::V2::Recognizer#model model}.
    END_OF_SINGLE_UTTERANCE = 1

    # This event indicates that the server has detected the beginning of human
    # voice activity in the stream. This event can be returned multiple times
    # if speech starts and stops repeatedly throughout the stream. This event
    # is only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_BEGIN = 2

    # This event indicates that the server has detected the end of human voice
    # activity in the stream. This event can be returned multiple times if
    # speech starts and stops repeatedly throughout the stream. This event is
    # only sent if `voice_activity_events` is set to true.
    SPEECH_ACTIVITY_END = 3
  end
end