Class StreamingRecognizeResponse.Builder (2.6.1)

public static final class StreamingRecognizeResponse.Builder extends GeneratedMessageV3.Builder<StreamingRecognizeResponse.Builder> 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 Methods

getDescriptor()

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

Methods

addAllResults(Iterable<? extends StreamingRecognitionResult> values)

public StreamingRecognizeResponse.Builder addAllResults(Iterable<? extends StreamingRecognitionResult> values)

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
valuesIterable<? extends com.google.cloud.speech.v1p1beta1.StreamingRecognitionResult>
Returns
TypeDescription
StreamingRecognizeResponse.Builder

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public StreamingRecognizeResponse.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
NameDescription
fieldFieldDescriptor
valueObject
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

addResults(StreamingRecognitionResult value)

public StreamingRecognizeResponse.Builder addResults(StreamingRecognitionResult value)

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
valueStreamingRecognitionResult
Returns
TypeDescription
StreamingRecognizeResponse.Builder

addResults(StreamingRecognitionResult.Builder builderForValue)

public StreamingRecognizeResponse.Builder addResults(StreamingRecognitionResult.Builder builderForValue)

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
builderForValueStreamingRecognitionResult.Builder
Returns
TypeDescription
StreamingRecognizeResponse.Builder

addResults(int index, StreamingRecognitionResult value)

public StreamingRecognizeResponse.Builder addResults(int index, StreamingRecognitionResult value)

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;

Parameters
NameDescription
indexint
valueStreamingRecognitionResult
Returns
TypeDescription
StreamingRecognizeResponse.Builder

addResults(int index, StreamingRecognitionResult.Builder builderForValue)

public StreamingRecognizeResponse.Builder addResults(int index, StreamingRecognitionResult.Builder builderForValue)

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;

Parameters
NameDescription
indexint
builderForValueStreamingRecognitionResult.Builder
Returns
TypeDescription
StreamingRecognizeResponse.Builder

addResultsBuilder()

public StreamingRecognitionResult.Builder addResultsBuilder()

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
StreamingRecognitionResult.Builder

addResultsBuilder(int index)

public StreamingRecognitionResult.Builder addResultsBuilder(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.Builder

build()

public StreamingRecognizeResponse build()
Returns
TypeDescription
StreamingRecognizeResponse

buildPartial()

public StreamingRecognizeResponse buildPartial()
Returns
TypeDescription
StreamingRecognizeResponse

clear()

public StreamingRecognizeResponse.Builder clear()
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

clearError()

public StreamingRecognizeResponse.Builder clearError()

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

.google.rpc.Status error = 1;

Returns
TypeDescription
StreamingRecognizeResponse.Builder

clearField(Descriptors.FieldDescriptor field)

public StreamingRecognizeResponse.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
NameDescription
fieldFieldDescriptor
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

clearOneof(Descriptors.OneofDescriptor oneof)

public StreamingRecognizeResponse.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
NameDescription
oneofOneofDescriptor
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

clearResults()

public StreamingRecognizeResponse.Builder clearResults()

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
StreamingRecognizeResponse.Builder

clearSpeechEventType()

public StreamingRecognizeResponse.Builder clearSpeechEventType()

Indicates the type of speech event.

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

Returns
TypeDescription
StreamingRecognizeResponse.Builder

This builder for chaining.

clearTotalBilledTime()

public StreamingRecognizeResponse.Builder clearTotalBilledTime()

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
StreamingRecognizeResponse.Builder

clone()

public StreamingRecognizeResponse.Builder clone()
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

getDefaultInstanceForType()

public StreamingRecognizeResponse getDefaultInstanceForType()
Returns
TypeDescription
StreamingRecognizeResponse

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
TypeDescription
Descriptor
Overrides

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.

getErrorBuilder()

public Status.Builder getErrorBuilder()

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

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

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

getResultsBuilder(int index)

public StreamingRecognitionResult.Builder getResultsBuilder(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.Builder

getResultsBuilderList()

public List<StreamingRecognitionResult.Builder> getResultsBuilderList()

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<Builder>

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>

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.

getTotalBilledTimeBuilder()

public Duration.Builder getTotalBilledTimeBuilder()

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
Builder

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.

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.

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
TypeDescription
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
TypeDescription
boolean
Overrides

mergeError(Status value)

public StreamingRecognizeResponse.Builder mergeError(Status value)

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

.google.rpc.Status error = 1;

Parameter
NameDescription
valuecom.google.rpc.Status
Returns
TypeDescription
StreamingRecognizeResponse.Builder

mergeFrom(StreamingRecognizeResponse other)

public StreamingRecognizeResponse.Builder mergeFrom(StreamingRecognizeResponse other)
Parameter
NameDescription
otherStreamingRecognizeResponse
Returns
TypeDescription
StreamingRecognizeResponse.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public StreamingRecognizeResponse.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides Exceptions
TypeDescription
IOException

mergeFrom(Message other)

public StreamingRecognizeResponse.Builder mergeFrom(Message other)
Parameter
NameDescription
otherMessage
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

mergeTotalBilledTime(Duration value)

public StreamingRecognizeResponse.Builder mergeTotalBilledTime(Duration value)

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;

Parameter
NameDescription
valueDuration
Returns
TypeDescription
StreamingRecognizeResponse.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final StreamingRecognizeResponse.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
NameDescription
unknownFieldsUnknownFieldSet
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

removeResults(int index)

public StreamingRecognizeResponse.Builder removeResults(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
StreamingRecognizeResponse.Builder

setError(Status value)

public StreamingRecognizeResponse.Builder setError(Status value)

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

.google.rpc.Status error = 1;

Parameter
NameDescription
valuecom.google.rpc.Status
Returns
TypeDescription
StreamingRecognizeResponse.Builder

setError(Status.Builder builderForValue)

public StreamingRecognizeResponse.Builder setError(Status.Builder builderForValue)

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

.google.rpc.Status error = 1;

Parameter
NameDescription
builderForValuecom.google.rpc.Status.Builder
Returns
TypeDescription
StreamingRecognizeResponse.Builder

setField(Descriptors.FieldDescriptor field, Object value)

public StreamingRecognizeResponse.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
NameDescription
fieldFieldDescriptor
valueObject
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

public StreamingRecognizeResponse.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
NameDescription
fieldFieldDescriptor
indexint
valueObject
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides

setResults(int index, StreamingRecognitionResult value)

public StreamingRecognizeResponse.Builder setResults(int index, StreamingRecognitionResult value)

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;

Parameters
NameDescription
indexint
valueStreamingRecognitionResult
Returns
TypeDescription
StreamingRecognizeResponse.Builder

setResults(int index, StreamingRecognitionResult.Builder builderForValue)

public StreamingRecognizeResponse.Builder setResults(int index, StreamingRecognitionResult.Builder builderForValue)

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;

Parameters
NameDescription
indexint
builderForValueStreamingRecognitionResult.Builder
Returns
TypeDescription
StreamingRecognizeResponse.Builder

setSpeechEventType(StreamingRecognizeResponse.SpeechEventType value)

public StreamingRecognizeResponse.Builder setSpeechEventType(StreamingRecognizeResponse.SpeechEventType value)

Indicates the type of speech event.

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

Parameter
NameDescription
valueStreamingRecognizeResponse.SpeechEventType

The speechEventType to set.

Returns
TypeDescription
StreamingRecognizeResponse.Builder

This builder for chaining.

setSpeechEventTypeValue(int value)

public StreamingRecognizeResponse.Builder setSpeechEventTypeValue(int value)

Indicates the type of speech event.

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

Parameter
NameDescription
valueint

The enum numeric value on the wire for speechEventType to set.

Returns
TypeDescription
StreamingRecognizeResponse.Builder

This builder for chaining.

setTotalBilledTime(Duration value)

public StreamingRecognizeResponse.Builder setTotalBilledTime(Duration value)

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;

Parameter
NameDescription
valueDuration
Returns
TypeDescription
StreamingRecognizeResponse.Builder

setTotalBilledTime(Duration.Builder builderForValue)

public StreamingRecognizeResponse.Builder setTotalBilledTime(Duration.Builder builderForValue)

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;

Parameter
NameDescription
builderForValueBuilder
Returns
TypeDescription
StreamingRecognizeResponse.Builder

setUnknownFields(UnknownFieldSet unknownFields)

public final StreamingRecognizeResponse.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
NameDescription
unknownFieldsUnknownFieldSet
Returns
TypeDescription
StreamingRecognizeResponse.Builder
Overrides