Reference documentation and code samples for the Cloud Speech V1 Client class StreamingRecognizeResponse.
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 StreamingRecognizeResponse
s that might be
returned while processing audio:
- results { alternatives { transcript: "tube" } stability: 0.01 }
- results { alternatives { transcript: "to be a" } stability: 0.01 }
- results { alternatives { transcript: "to be" } stability: 0.9 } results { alternatives { transcript: " or not to be" } stability: 0.01 }
- results { alternatives { transcript: "to be or not to be" confidence: 0.92 } alternatives { transcript: "to bee or not to bee" } is_final: true }
- results { alternatives { transcript: " that's" } stability: 0.01 }
- results { alternatives { transcript: " that is" } stability: 0.9 } results { alternatives { transcript: " the question" } stability: 0.01 }
- 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 interimresults
: 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 stabilityresults
. - The specific
stability
andconfidence
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
.
Generated from protobuf message google.cloud.speech.v1.StreamingRecognizeResponse
Namespace
Google \ Cloud \ Speech \ V1Methods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
data |
array
Optional. Data for populating the Message object. |
↳ error |
Google\Rpc\Status
If set, returns a google.rpc.Status message that specifies the error for the operation. |
↳ results |
array<StreamingRecognitionResult>
This repeated list contains zero or more results that correspond to consecutive portions of the audio currently being processed. It contains zero or one |
↳ speech_event_type |
int
Indicates the type of speech event. |
↳ speech_event_time |
Google\Protobuf\Duration
Time offset between the beginning of the audio and event emission. |
↳ total_billed_time |
Google\Protobuf\Duration
When available, billed audio seconds for the stream. Set only if this is the last response in the stream. |
↳ speech_adaptation_info |
SpeechAdaptationInfo
Provides information on adaptation behavior in response |
↳ request_id |
int|string
The ID associated with the request. This is a unique ID specific only to the given request. |
getError
If set, returns a google.rpc.Status message that specifies the error for the operation.
Returns | |
---|---|
Type | Description |
Google\Rpc\Status|null |
hasError
clearError
setError
If set, returns a google.rpc.Status message that specifies the error for the operation.
Parameter | |
---|---|
Name | Description |
var |
Google\Rpc\Status
|
Returns | |
---|---|
Type | Description |
$this |
getResults
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 | |
---|---|
Type | Description |
Google\Protobuf\Internal\RepeatedField |
setResults
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).
Parameter | |
---|---|
Name | Description |
var |
array<StreamingRecognitionResult>
|
Returns | |
---|---|
Type | Description |
$this |
getSpeechEventType
Indicates the type of speech event.
Returns | |
---|---|
Type | Description |
int |
setSpeechEventType
Indicates the type of speech event.
Parameter | |
---|---|
Name | Description |
var |
int
|
Returns | |
---|---|
Type | Description |
$this |
getSpeechEventTime
Time offset between the beginning of the audio and event emission.
Returns | |
---|---|
Type | Description |
Google\Protobuf\Duration|null |
hasSpeechEventTime
clearSpeechEventTime
setSpeechEventTime
Time offset between the beginning of the audio and event emission.
Parameter | |
---|---|
Name | Description |
var |
Google\Protobuf\Duration
|
Returns | |
---|---|
Type | Description |
$this |
getTotalBilledTime
When available, billed audio seconds for the stream.
Set only if this is the last response in the stream.
Returns | |
---|---|
Type | Description |
Google\Protobuf\Duration|null |
hasTotalBilledTime
clearTotalBilledTime
setTotalBilledTime
When available, billed audio seconds for the stream.
Set only if this is the last response in the stream.
Parameter | |
---|---|
Name | Description |
var |
Google\Protobuf\Duration
|
Returns | |
---|---|
Type | Description |
$this |
getSpeechAdaptationInfo
Provides information on adaptation behavior in response
Returns | |
---|---|
Type | Description |
SpeechAdaptationInfo|null |
hasSpeechAdaptationInfo
clearSpeechAdaptationInfo
setSpeechAdaptationInfo
Provides information on adaptation behavior in response
Parameter | |
---|---|
Name | Description |
var |
SpeechAdaptationInfo
|
Returns | |
---|---|
Type | Description |
$this |
getRequestId
The ID associated with the request. This is a unique ID specific only to the given request.
Returns | |
---|---|
Type | Description |
int|string |
setRequestId
The ID associated with the request. This is a unique ID specific only to the given request.
Parameter | |
---|---|
Name | Description |
var |
int|string
|
Returns | |
---|---|
Type | Description |
$this |