Class StreamingRecognizeResponse.Builder (4.43.0)

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

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
values Iterable<? extends com.google.cloud.speech.v2.StreamingRecognitionResult>
Returns
Type Description
StreamingRecognizeResponse.Builder

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public StreamingRecognizeResponse.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
value StreamingRecognitionResult
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
builderForValue StreamingRecognitionResult.Builder
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameters
Name Description
index int
value StreamingRecognitionResult
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameters
Name Description
index int
builderForValue StreamingRecognitionResult.Builder
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
index int
Returns
Type Description
StreamingRecognitionResult.Builder

build()

public StreamingRecognizeResponse build()
Returns
Type Description
StreamingRecognizeResponse

buildPartial()

public StreamingRecognizeResponse buildPartial()
Returns
Type Description
StreamingRecognizeResponse

clear()

public StreamingRecognizeResponse.Builder clear()
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides

clearField(Descriptors.FieldDescriptor field)

public StreamingRecognizeResponse.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field FieldDescriptor
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides

clearMetadata()

public StreamingRecognizeResponse.Builder clearMetadata()

Metadata about the recognition.

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

Returns
Type Description
StreamingRecognizeResponse.Builder

clearOneof(Descriptors.OneofDescriptor oneof)

public StreamingRecognizeResponse.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
Name Description
oneof OneofDescriptor
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Returns
Type Description
StreamingRecognizeResponse.Builder

clearSpeechEventOffset()

public StreamingRecognizeResponse.Builder clearSpeechEventOffset()

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

.google.protobuf.Duration speech_event_offset = 7;

Returns
Type Description
StreamingRecognizeResponse.Builder

clearSpeechEventType()

public StreamingRecognizeResponse.Builder clearSpeechEventType()

Indicates the type of speech event.

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

Returns
Type Description
StreamingRecognizeResponse.Builder

This builder for chaining.

clone()

public StreamingRecognizeResponse.Builder clone()
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides

getDefaultInstanceForType()

public StreamingRecognizeResponse getDefaultInstanceForType()
Returns
Type Description
StreamingRecognizeResponse

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
Overrides

getMetadata()

public RecognitionResponseMetadata getMetadata()

Metadata about the recognition.

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

Returns
Type Description
RecognitionResponseMetadata

The metadata.

getMetadataBuilder()

public RecognitionResponseMetadata.Builder getMetadataBuilder()

Metadata about the recognition.

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

Returns
Type Description
RecognitionResponseMetadata.Builder

getMetadataOrBuilder()

public RecognitionResponseMetadataOrBuilder getMetadataOrBuilder()

Metadata about the recognition.

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

Returns
Type Description
RecognitionResponseMetadataOrBuilder

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

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.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
index int
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Returns
Type Description
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.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>

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.

getSpeechEventOffsetBuilder()

public Duration.Builder getSpeechEventOffsetBuilder()

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

.google.protobuf.Duration speech_event_offset = 7;

Returns
Type Description
Builder

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.

internalGetFieldAccessorTable()

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

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeFrom(StreamingRecognizeResponse other)

public StreamingRecognizeResponse.Builder mergeFrom(StreamingRecognizeResponse other)
Parameter
Name Description
other StreamingRecognizeResponse
Returns
Type Description
StreamingRecognizeResponse.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public StreamingRecognizeResponse.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public StreamingRecognizeResponse.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides

mergeMetadata(RecognitionResponseMetadata value)

public StreamingRecognizeResponse.Builder mergeMetadata(RecognitionResponseMetadata value)

Metadata about the recognition.

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

Parameter
Name Description
value RecognitionResponseMetadata
Returns
Type Description
StreamingRecognizeResponse.Builder

mergeSpeechEventOffset(Duration value)

public StreamingRecognizeResponse.Builder mergeSpeechEventOffset(Duration value)

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

.google.protobuf.Duration speech_event_offset = 7;

Parameter
Name Description
value Duration
Returns
Type Description
StreamingRecognizeResponse.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final StreamingRecognizeResponse.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameter
Name Description
index int
Returns
Type Description
StreamingRecognizeResponse.Builder

setField(Descriptors.FieldDescriptor field, Object value)

public StreamingRecognizeResponse.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides

setMetadata(RecognitionResponseMetadata value)

public StreamingRecognizeResponse.Builder setMetadata(RecognitionResponseMetadata value)

Metadata about the recognition.

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

Parameter
Name Description
value RecognitionResponseMetadata
Returns
Type Description
StreamingRecognizeResponse.Builder

setMetadata(RecognitionResponseMetadata.Builder builderForValue)

public StreamingRecognizeResponse.Builder setMetadata(RecognitionResponseMetadata.Builder builderForValue)

Metadata about the recognition.

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

Parameter
Name Description
builderForValue RecognitionResponseMetadata.Builder
Returns
Type Description
StreamingRecognizeResponse.Builder

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

public StreamingRecognizeResponse.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Name Description
field FieldDescriptor
index int
value Object
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameters
Name Description
index int
value StreamingRecognitionResult
Returns
Type Description
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.v2.StreamingRecognitionResult results = 6;

Parameters
Name Description
index int
builderForValue StreamingRecognitionResult.Builder
Returns
Type Description
StreamingRecognizeResponse.Builder

setSpeechEventOffset(Duration value)

public StreamingRecognizeResponse.Builder setSpeechEventOffset(Duration value)

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

.google.protobuf.Duration speech_event_offset = 7;

Parameter
Name Description
value Duration
Returns
Type Description
StreamingRecognizeResponse.Builder

setSpeechEventOffset(Duration.Builder builderForValue)

public StreamingRecognizeResponse.Builder setSpeechEventOffset(Duration.Builder builderForValue)

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

.google.protobuf.Duration speech_event_offset = 7;

Parameter
Name Description
builderForValue Builder
Returns
Type Description
StreamingRecognizeResponse.Builder

setSpeechEventType(StreamingRecognizeResponse.SpeechEventType value)

public StreamingRecognizeResponse.Builder setSpeechEventType(StreamingRecognizeResponse.SpeechEventType value)

Indicates the type of speech event.

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

Parameter
Name Description
value StreamingRecognizeResponse.SpeechEventType

The speechEventType to set.

Returns
Type Description
StreamingRecognizeResponse.Builder

This builder for chaining.

setSpeechEventTypeValue(int value)

public StreamingRecognizeResponse.Builder setSpeechEventTypeValue(int value)

Indicates the type of speech event.

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

Parameter
Name Description
value int

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

Returns
Type Description
StreamingRecognizeResponse.Builder

This builder for chaining.

setUnknownFields(UnknownFieldSet unknownFields)

public final StreamingRecognizeResponse.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
StreamingRecognizeResponse.Builder
Overrides