Class StreamingRecognizeResponse (4.50.0)

public final class StreamingRecognizeResponse extends GeneratedMessageV3 implements StreamingRecognizeResponseOrBuilder

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:

  8. 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".

  9. 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.

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

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

Protobuf type google.cloud.speech.v2.StreamingRecognizeResponse

Static Fields

METADATA_FIELD_NUMBER

public static final int METADATA_FIELD_NUMBER
Field Value
Type Description
int

RESULTS_FIELD_NUMBER

public static final int RESULTS_FIELD_NUMBER
Field Value
Type Description
int

SPEECH_EVENT_OFFSET_FIELD_NUMBER

public static final int SPEECH_EVENT_OFFSET_FIELD_NUMBER
Field Value
Type Description
int

SPEECH_EVENT_TYPE_FIELD_NUMBER

public static final int SPEECH_EVENT_TYPE_FIELD_NUMBER
Field Value
Type Description
int

Static Methods

getDefaultInstance()

public static StreamingRecognizeResponse getDefaultInstance()
Returns
Type Description
StreamingRecognizeResponse

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

newBuilder()

public static StreamingRecognizeResponse.Builder newBuilder()
Returns
Type Description
StreamingRecognizeResponse.Builder

newBuilder(StreamingRecognizeResponse prototype)

public static StreamingRecognizeResponse.Builder newBuilder(StreamingRecognizeResponse prototype)
Parameter
Name Description
prototype StreamingRecognizeResponse
Returns
Type Description
StreamingRecognizeResponse.Builder

parseDelimitedFrom(InputStream input)

public static StreamingRecognizeResponse parseDelimitedFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
IOException

parseFrom(byte[] data)

public static StreamingRecognizeResponse parseFrom(byte[] data)
Parameter
Name Description
data byte[]
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data byte[]
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data)

public static StreamingRecognizeResponse parseFrom(ByteString data)
Parameter
Name Description
data ByteString
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static StreamingRecognizeResponse parseFrom(CodedInputStream input)
Parameter
Name Description
input CodedInputStream
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
IOException

parseFrom(InputStream input)

public static StreamingRecognizeResponse parseFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
IOException

parseFrom(ByteBuffer data)

public static StreamingRecognizeResponse parseFrom(ByteBuffer data)
Parameter
Name Description
data ByteBuffer
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteBuffer
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StreamingRecognizeResponse
Exceptions
Type Description
InvalidProtocolBufferException

parser()

public static Parser<StreamingRecognizeResponse> parser()
Returns
Type Description
Parser<StreamingRecognizeResponse>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
Name Description
obj Object
Returns
Type Description
boolean
Overrides

getDefaultInstanceForType()

public StreamingRecognizeResponse getDefaultInstanceForType()
Returns
Type Description
StreamingRecognizeResponse

getMetadata()

public RecognitionResponseMetadata getMetadata()

Metadata about the recognition.

.google.cloud.speech.v2.RecognitionResponseMetadata metadata = 5;

Returns
Type Description
RecognitionResponseMetadata

The metadata.

getMetadataOrBuilder()

public RecognitionResponseMetadataOrBuilder getMetadataOrBuilder()

Metadata about the recognition.

.google.cloud.speech.v2.RecognitionResponseMetadata metadata = 5;

Returns
Type Description
RecognitionResponseMetadataOrBuilder

getParserForType()

public Parser<StreamingRecognizeResponse> getParserForType()
Returns
Type Description
Parser<StreamingRecognizeResponse>
Overrides

getResults(int index)

public StreamingRecognitionResult getResults(int index)

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).

repeated .google.cloud.speech.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
index int
Returns
Type Description
StreamingRecognitionResult

getResultsCount()

public int getResultsCount()

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).

repeated .google.cloud.speech.v2.StreamingRecognitionResult results = 6;

Returns
Type Description
int

getResultsList()

public List<StreamingRecognitionResult> getResultsList()

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).

repeated .google.cloud.speech.v2.StreamingRecognitionResult results = 6;

Returns
Type Description
List<StreamingRecognitionResult>

getResultsOrBuilder(int index)

public StreamingRecognitionResultOrBuilder getResultsOrBuilder(int index)

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).

repeated .google.cloud.speech.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
index int
Returns
Type Description
StreamingRecognitionResultOrBuilder

getResultsOrBuilderList()

public List<? extends StreamingRecognitionResultOrBuilder> getResultsOrBuilderList()

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).

repeated .google.cloud.speech.v2.StreamingRecognitionResult results = 6;

Returns
Type Description
List<? extends com.google.cloud.speech.v2.StreamingRecognitionResultOrBuilder>

getSerializedSize()

public int getSerializedSize()
Returns
Type Description
int
Overrides

getSpeechEventOffset()

public Duration getSpeechEventOffset()

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

.google.protobuf.Duration speech_event_offset = 7;

Returns
Type Description
Duration

The speechEventOffset.

getSpeechEventOffsetOrBuilder()

public DurationOrBuilder getSpeechEventOffsetOrBuilder()

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

.google.protobuf.Duration speech_event_offset = 7;

Returns
Type Description
DurationOrBuilder

getSpeechEventType()

public StreamingRecognizeResponse.SpeechEventType getSpeechEventType()

Indicates the type of speech event.

.google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType speech_event_type = 3;

Returns
Type Description
StreamingRecognizeResponse.SpeechEventType

The speechEventType.

getSpeechEventTypeValue()

public int getSpeechEventTypeValue()

Indicates the type of speech event.

.google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType speech_event_type = 3;

Returns
Type Description
int

The enum numeric value on the wire for speechEventType.

hasMetadata()

public boolean hasMetadata()

Metadata about the recognition.

.google.cloud.speech.v2.RecognitionResponseMetadata metadata = 5;

Returns
Type Description
boolean

Whether the metadata field is set.

hasSpeechEventOffset()

public boolean hasSpeechEventOffset()

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

.google.protobuf.Duration speech_event_offset = 7;

Returns
Type Description
boolean

Whether the speechEventOffset field is set.

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

newBuilderForType()

public StreamingRecognizeResponse.Builder newBuilderForType()
Returns
Type Description
StreamingRecognizeResponse.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected StreamingRecognizeResponse.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
Name Description
parent BuilderParent
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
Name Description
unused UnusedPrivateParameter
Returns
Type Description
Object
Overrides

toBuilder()

public StreamingRecognizeResponse.Builder toBuilder()
Returns
Type Description
StreamingRecognizeResponse.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
Name Description
output CodedOutputStream
Overrides
Exceptions
Type Description
IOException