# Cloud Speech V2 Client - Class StreamingRecognizeResponse (2.5.1)

2.5.1 (latest) 2.5.0 2.4.0 2.3.0 2.2.1 2.1.1 2.0.1 1.20.1 1.19.2 1.18.3 1.16.0 1.15.0 1.14.3 1.13.1 1.12.0 1.11.2 1.10.0 1.9.1 1.8.0 1.7.0 Reference documentation and code samples for the Cloud Speech V2 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 then no messages are streamed back to the client.

Here are some examples of `StreamingRecognizeResponse`s 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`.

Generated from protobuf message `google.cloud.speech.v2.StreamingRecognizeResponse`

## Namespace

Google \\ Cloud \\ Speech \\ V2

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ results` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.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 [is_final](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult#_Google_Cloud_Speech_V2_StreamingRecognitionResult__getIsFinal__)=`true` result (the newly settled portion), followed by zero or more [is_final](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult#_Google_Cloud_Speech_V2_StreamingRecognitionResult__getIsFinal__)=`false` results (the interim results). |
| `↳ speech_event_type` | `int` Indicates the type of speech event. |
| `↳ speech_event_offset` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Duration` Time offset between the beginning of the audio and event emission. |
| `↳ metadata` | `https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.RecognitionResponseMetadata` Metadata about the recognition. |

### 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](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult#_Google_Cloud_Speech_V2_StreamingRecognitionResult__getIsFinal__)=`true`
result (the newly settled portion), followed by zero or more
[is_final](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult#_Google_Cloud_Speech_V2_StreamingRecognitionResult__getIsFinal__)=`false`
results (the interim results).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult>` |   |

### 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](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult#_Google_Cloud_Speech_V2_StreamingRecognitionResult__getIsFinal__)=`true`
result (the newly settled portion), followed by zero or more
[is_final](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult#_Google_Cloud_Speech_V2_StreamingRecognitionResult__getIsFinal__)=`false`
results (the interim results).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognitionResult>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSpeechEventType

Indicates the type of speech event.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [SpeechEventType](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognizeResponse.SpeechEventType). |

### setSpeechEventType

Indicates the type of speech event.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [SpeechEventType](https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.StreamingRecognizeResponse.SpeechEventType). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSpeechEventOffset

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Duration|null` |   |

### hasSpeechEventOffset

### clearSpeechEventOffset

### setSpeechEventOffset

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

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Duration` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMetadata

Metadata about the recognition.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.RecognitionResponseMetadata|null` |   |

### hasMetadata

### clearMetadata

### setMetadata

Metadata about the recognition.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-speech/latest/V2.RecognitionResponseMetadata` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |