Class StreamingRecognizeResponse (4.36.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, and single_utterance is set to false, then no messages are streamed back to the client.

Here's an example of a series 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.v1p1beta1.StreamingRecognizeResponse

Static Fields

ERROR_FIELD_NUMBER

public static final int ERROR_FIELD_NUMBER
Field Value
TypeDescription
int

REQUEST_ID_FIELD_NUMBER

public static final int REQUEST_ID_FIELD_NUMBER
Field Value
TypeDescription
int

RESULTS_FIELD_NUMBER

public static final int RESULTS_FIELD_NUMBER
Field Value
TypeDescription
int

SPEECH_ADAPTATION_INFO_FIELD_NUMBER

public static final int SPEECH_ADAPTATION_INFO_FIELD_NUMBER
Field Value
TypeDescription
int

SPEECH_EVENT_TIME_FIELD_NUMBER

public static final int SPEECH_EVENT_TIME_FIELD_NUMBER
Field Value
TypeDescription
int

SPEECH_EVENT_TYPE_FIELD_NUMBER

public static final int SPEECH_EVENT_TYPE_FIELD_NUMBER
Field Value
TypeDescription
int

TOTAL_BILLED_TIME_FIELD_NUMBER

public static final int TOTAL_BILLED_TIME_FIELD_NUMBER
Field Value
TypeDescription
int

Static Methods

getDefaultInstance()

public static StreamingRecognizeResponse getDefaultInstance()
Returns
TypeDescription
StreamingRecognizeResponse

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
TypeDescription
Descriptor

newBuilder()

public static StreamingRecognizeResponse.Builder newBuilder()
Returns
TypeDescription
StreamingRecognizeResponse.Builder

newBuilder(StreamingRecognizeResponse prototype)

public static StreamingRecognizeResponse.Builder newBuilder(StreamingRecognizeResponse prototype)
Parameter
NameDescription
prototypeStreamingRecognizeResponse
Returns
TypeDescription
StreamingRecognizeResponse.Builder

parseDelimitedFrom(InputStream input)

public static StreamingRecognizeResponse parseDelimitedFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
IOException

parseFrom(byte[] data)

public static StreamingRecognizeResponse parseFrom(byte[] data)
Parameter
NameDescription
databyte[]
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
databyte[]
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data)

public static StreamingRecognizeResponse parseFrom(ByteString data)
Parameter
NameDescription
dataByteString
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteString
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static StreamingRecognizeResponse parseFrom(CodedInputStream input)
Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
IOException

parseFrom(InputStream input)

public static StreamingRecognizeResponse parseFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
IOException

parseFrom(ByteBuffer data)

public static StreamingRecognizeResponse parseFrom(ByteBuffer data)
Parameter
NameDescription
dataByteBuffer
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static StreamingRecognizeResponse parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteBuffer
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
StreamingRecognizeResponse
Exceptions
TypeDescription
InvalidProtocolBufferException

parser()

public static Parser<StreamingRecognizeResponse> parser()
Returns
TypeDescription
Parser<StreamingRecognizeResponse>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
NameDescription
objObject
Returns
TypeDescription
boolean
Overrides

getDefaultInstanceForType()

public StreamingRecognizeResponse getDefaultInstanceForType()
Returns
TypeDescription
StreamingRecognizeResponse

getError()

public Status getError()

If set, returns a google.rpc.Status message that specifies the error for the operation.

.google.rpc.Status error = 1;

Returns
TypeDescription
com.google.rpc.Status

The error.

getErrorOrBuilder()

public StatusOrBuilder getErrorOrBuilder()

If set, returns a google.rpc.Status message that specifies the error for the operation.

.google.rpc.Status error = 1;

Returns
TypeDescription
com.google.rpc.StatusOrBuilder

getParserForType()

public Parser<StreamingRecognizeResponse> getParserForType()
Returns
TypeDescription
Parser<StreamingRecognizeResponse>
Overrides

getRequestId()

public long getRequestId()

The ID associated with the request. This is a unique ID specific only to the given request.

int64 request_id = 10;

Returns
TypeDescription
long

The requestId.

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.v1p1beta1.StreamingRecognitionResult results = 2;

Parameter
NameDescription
indexint
Returns
TypeDescription
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.v1p1beta1.StreamingRecognitionResult results = 2;

Returns
TypeDescription
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.v1p1beta1.StreamingRecognitionResult results = 2;

Returns
TypeDescription
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.v1p1beta1.StreamingRecognitionResult results = 2;

Parameter
NameDescription
indexint
Returns
TypeDescription
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.v1p1beta1.StreamingRecognitionResult results = 2;

Returns
TypeDescription
List<? extends com.google.cloud.speech.v1p1beta1.StreamingRecognitionResultOrBuilder>

getSerializedSize()

public int getSerializedSize()
Returns
TypeDescription
int
Overrides

getSpeechAdaptationInfo()

public SpeechAdaptationInfo getSpeechAdaptationInfo()

Provides information on adaptation behavior in response

.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo speech_adaptation_info = 9;

Returns
TypeDescription
SpeechAdaptationInfo

The speechAdaptationInfo.

getSpeechAdaptationInfoOrBuilder()

public SpeechAdaptationInfoOrBuilder getSpeechAdaptationInfoOrBuilder()

Provides information on adaptation behavior in response

.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo speech_adaptation_info = 9;

Returns
TypeDescription
SpeechAdaptationInfoOrBuilder

getSpeechEventTime()

public Duration getSpeechEventTime()

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

.google.protobuf.Duration speech_event_time = 8;

Returns
TypeDescription
Duration

The speechEventTime.

getSpeechEventTimeOrBuilder()

public DurationOrBuilder getSpeechEventTimeOrBuilder()

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

.google.protobuf.Duration speech_event_time = 8;

Returns
TypeDescription
DurationOrBuilder

getSpeechEventType()

public StreamingRecognizeResponse.SpeechEventType getSpeechEventType()

Indicates the type of speech event.

.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType speech_event_type = 4;

Returns
TypeDescription
StreamingRecognizeResponse.SpeechEventType

The speechEventType.

getSpeechEventTypeValue()

public int getSpeechEventTypeValue()

Indicates the type of speech event.

.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType speech_event_type = 4;

Returns
TypeDescription
int

The enum numeric value on the wire for speechEventType.

getTotalBilledTime()

public Duration getTotalBilledTime()

When available, billed audio seconds for the stream. Set only if this is the last response in the stream.

.google.protobuf.Duration total_billed_time = 5;

Returns
TypeDescription
Duration

The totalBilledTime.

getTotalBilledTimeOrBuilder()

public DurationOrBuilder getTotalBilledTimeOrBuilder()

When available, billed audio seconds for the stream. Set only if this is the last response in the stream.

.google.protobuf.Duration total_billed_time = 5;

Returns
TypeDescription
DurationOrBuilder

hasError()

public boolean hasError()

If set, returns a google.rpc.Status message that specifies the error for the operation.

.google.rpc.Status error = 1;

Returns
TypeDescription
boolean

Whether the error field is set.

hasSpeechAdaptationInfo()

public boolean hasSpeechAdaptationInfo()

Provides information on adaptation behavior in response

.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo speech_adaptation_info = 9;

Returns
TypeDescription
boolean

Whether the speechAdaptationInfo field is set.

hasSpeechEventTime()

public boolean hasSpeechEventTime()

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

.google.protobuf.Duration speech_event_time = 8;

Returns
TypeDescription
boolean

Whether the speechEventTime field is set.

hasTotalBilledTime()

public boolean hasTotalBilledTime()

When available, billed audio seconds for the stream. Set only if this is the last response in the stream.

.google.protobuf.Duration total_billed_time = 5;

Returns
TypeDescription
boolean

Whether the totalBilledTime field is set.

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
TypeDescription
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
TypeDescription
boolean
Overrides

newBuilderForType()

public StreamingRecognizeResponse.Builder newBuilderForType()
Returns
TypeDescription
StreamingRecognizeResponse.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected StreamingRecognizeResponse.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
NameDescription
parentBuilderParent
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
NameDescription
unusedUnusedPrivateParameter
Returns
TypeDescription
Object
Overrides

toBuilder()

public StreamingRecognizeResponse.Builder toBuilder()
Returns
TypeDescription
StreamingRecognizeResponse.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
NameDescription
outputCodedOutputStream
Overrides
Exceptions
TypeDescription
IOException