# Google Cloud Speech v1 API - Class SpeechClient (3.9.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [3.9.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient)
- [3.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.8.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.7.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.7.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.6.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.5.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.4.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.3.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.2.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.1.0/Google.Cloud.Speech.V1.SpeechClient)
- [3.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/3.0.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.9.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.9.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.8.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.7.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.7.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.6.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.5.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.4.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.3.0/Google.Cloud.Speech.V1.SpeechClient)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/2.2.0/Google.Cloud.Speech.V1.SpeechClient)

    public abstract class SpeechClient

Reference documentation and code samples for the Google Cloud Speech v1 API class SpeechClient.

Speech client wrapper, for convenient use.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> SpeechClient

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Derived Types

[SpeechClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClientImpl)

## Namespace

[Google.Cloud.Speech.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1)

## Assembly

Google.Cloud.Speech.V1.dll

## Remarks

Service that implements Google Cloud Speech API.

## Properties

### DefaultEndpoint

    public static string DefaultEndpoint { get; }

The default endpoint for the Speech service, which is a host of "speech.googleapis.com" and a port of 443.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### DefaultScopes

    public static IReadOnlyList<string> DefaultScopes { get; }

The default Speech scopes.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1https://learn.microsoft.com/dotnet/api/system.string` |   |

**Remarks** The default Speech scopes are:

- <https://www.googleapis.com/auth/cloud-platform>

<br />

### GrpcClient

    public virtual Speech.SpeechClient GrpcClient { get; }

The underlying gRPC Speech client

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.Speechhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.Speech.SpeechClient` |   |

### LongRunningRecognizeOperationsClient

    public virtual OperationsClient LongRunningRecognizeOperationsClient { get; }

The long-running operations client for `LongRunningRecognize`.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.OperationsClient.html` |   |

### ServiceMetadata

    public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ServiceMetadata.html` |   |

## Methods

### Create()

    public static SpeechClient Create()

Synchronously creates a [SpeechClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient) using the default credentials, endpoint and settings. To
specify custom credentials or other settings, use [SpeechClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClientBuilder).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient` | The created [SpeechClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient). |

### CreateAsync(CancellationToken)

    public static Task<SpeechClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a [SpeechClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient) using the default credentials, endpoint and settings. To
specify custom credentials or other settings, use [SpeechClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClientBuilder).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use while creating the client. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient` | The task representing the created [SpeechClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient). |

### LongRunningRecognize(LongRunningRecognizeRequest, CallSettings)

    public virtual Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> LongRunningRecognize(LongRunningRecognizeRequest request, CallSettings callSettings = null)

Performs asynchronous speech recognition: receive results via the
google.longrunning.Operations interface. Returns either an
`Operation.error` or an `Operation.response` which contains
a `LongRunningRecognizeResponse` message.
For more information on asynchronous speech recognition, see the
[how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | The RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = SpeechClient.Create();
    // Initialize request argument(s)
    LongRunningRecognizeRequest request = new LongRunningRecognizeRequest
    {
        Config = new RecognitionConfig(),
        Audio = new RecognitionAudio(),
        OutputConfig = new TranscriptOutputConfig(),
    };
    // Make the request
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> response = speechClient.LongRunningRecognize(request);

    // Poll until the returned long-running operation is complete
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> completedResponse = response.PollUntilCompleted();
    // Retrieve the operation result
    LongRunningRecognizeResponse result = completedResponse.Result;

    // Or get the name of the operation
    string operationName = response.Name;
    // This name can be stored, then the long-running operation retrieved later by name
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> retrievedResponse = speechClient.PollOnceLongRunningRecognize(operationName);
    // Check if the retrieved long-running operation has completed
    if (retrievedResponse.IsCompleted)
    {
        // If it has completed, then access the result
        LongRunningRecognizeResponse retrievedResult = retrievedResponse.Result;
    }

### LongRunningRecognize(RecognitionConfig, RecognitionAudio, CallSettings)

    public virtual Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> LongRunningRecognize(RecognitionConfig config, RecognitionAudio audio, CallSettings callSettings = null)

Performs asynchronous speech recognition: receive results via the
google.longrunning.Operations interface. Returns either an
`Operation.error` or an `Operation.response` which contains
a `LongRunningRecognizeResponse` message.
For more information on asynchronous speech recognition, see the
[how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `config` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionConfig` Required. Provides information to the recognizer that specifies how to process the request. |
| `audio` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio` Required. The audio data to be recognized. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | The RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = SpeechClient.Create();
    // Initialize request argument(s)
    RecognitionConfig config = new RecognitionConfig();
    RecognitionAudio audio = new RecognitionAudio();
    // Make the request
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> response = speechClient.LongRunningRecognize(config, audio);

    // Poll until the returned long-running operation is complete
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> completedResponse = response.PollUntilCompleted();
    // Retrieve the operation result
    LongRunningRecognizeResponse result = completedResponse.Result;

    // Or get the name of the operation
    string operationName = response.Name;
    // This name can be stored, then the long-running operation retrieved later by name
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> retrievedResponse = speechClient.PollOnceLongRunningRecognize(operationName);
    // Check if the retrieved long-running operation has completed
    if (retrievedResponse.IsCompleted)
    {
        // If it has completed, then access the result
        LongRunningRecognizeResponse retrievedResult = retrievedResponse.Result;
    }

### LongRunningRecognizeAsync(LongRunningRecognizeRequest, CallSettings)

    public virtual Task<Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata>> LongRunningRecognizeAsync(LongRunningRecognizeRequest request, CallSettings callSettings = null)

Performs asynchronous speech recognition: receive results via the
google.longrunning.Operations interface. Returns either an
`Operation.error` or an `Operation.response` which contains
a `LongRunningRecognizeResponse` message.
For more information on asynchronous speech recognition, see the
[how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    LongRunningRecognizeRequest request = new LongRunningRecognizeRequest
    {
        Config = new RecognitionConfig(),
        Audio = new RecognitionAudio(),
        OutputConfig = new TranscriptOutputConfig(),
    };
    // Make the request
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> response = await speechClient.LongRunningRecognizeAsync(request);

    // Poll until the returned long-running operation is complete
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> completedResponse = await response.PollUntilCompletedAsync();
    // Retrieve the operation result
    LongRunningRecognizeResponse result = completedResponse.Result;

    // Or get the name of the operation
    string operationName = response.Name;
    // This name can be stored, then the long-running operation retrieved later by name
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> retrievedResponse = await speechClient.PollOnceLongRunningRecognizeAsync(operationName);
    // Check if the retrieved long-running operation has completed
    if (retrievedResponse.IsCompleted)
    {
        // If it has completed, then access the result
        LongRunningRecognizeResponse retrievedResult = retrievedResponse.Result;
    }

### LongRunningRecognizeAsync(LongRunningRecognizeRequest, CancellationToken)

    public virtual Task<Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata>> LongRunningRecognizeAsync(LongRunningRecognizeRequest request, CancellationToken cancellationToken)

Performs asynchronous speech recognition: receive results via the
google.longrunning.Operations interface. Returns either an
`Operation.error` or an `Operation.response` which contains
a `LongRunningRecognizeResponse` message.
For more information on asynchronous speech recognition, see the
[how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    LongRunningRecognizeRequest request = new LongRunningRecognizeRequest
    {
        Config = new RecognitionConfig(),
        Audio = new RecognitionAudio(),
        OutputConfig = new TranscriptOutputConfig(),
    };
    // Make the request
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> response = await speechClient.LongRunningRecognizeAsync(request);

    // Poll until the returned long-running operation is complete
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> completedResponse = await response.PollUntilCompletedAsync();
    // Retrieve the operation result
    LongRunningRecognizeResponse result = completedResponse.Result;

    // Or get the name of the operation
    string operationName = response.Name;
    // This name can be stored, then the long-running operation retrieved later by name
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> retrievedResponse = await speechClient.PollOnceLongRunningRecognizeAsync(operationName);
    // Check if the retrieved long-running operation has completed
    if (retrievedResponse.IsCompleted)
    {
        // If it has completed, then access the result
        LongRunningRecognizeResponse retrievedResult = retrievedResponse.Result;
    }

### LongRunningRecognizeAsync(RecognitionConfig, RecognitionAudio, CallSettings)

    public virtual Task<Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata>> LongRunningRecognizeAsync(RecognitionConfig config, RecognitionAudio audio, CallSettings callSettings = null)

Performs asynchronous speech recognition: receive results via the
google.longrunning.Operations interface. Returns either an
`Operation.error` or an `Operation.response` which contains
a `LongRunningRecognizeResponse` message.
For more information on asynchronous speech recognition, see the
[how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `config` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionConfig` Required. Provides information to the recognizer that specifies how to process the request. |
| `audio` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio` Required. The audio data to be recognized. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    RecognitionConfig config = new RecognitionConfig();
    RecognitionAudio audio = new RecognitionAudio();
    // Make the request
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> response = await speechClient.LongRunningRecognizeAsync(config, audio);

    // Poll until the returned long-running operation is complete
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> completedResponse = await response.PollUntilCompletedAsync();
    // Retrieve the operation result
    LongRunningRecognizeResponse result = completedResponse.Result;

    // Or get the name of the operation
    string operationName = response.Name;
    // This name can be stored, then the long-running operation retrieved later by name
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> retrievedResponse = await speechClient.PollOnceLongRunningRecognizeAsync(operationName);
    // Check if the retrieved long-running operation has completed
    if (retrievedResponse.IsCompleted)
    {
        // If it has completed, then access the result
        LongRunningRecognizeResponse retrievedResult = retrievedResponse.Result;
    }

### LongRunningRecognizeAsync(RecognitionConfig, RecognitionAudio, CancellationToken)

    public virtual Task<Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata>> LongRunningRecognizeAsync(RecognitionConfig config, RecognitionAudio audio, CancellationToken cancellationToken)

Performs asynchronous speech recognition: receive results via the
google.longrunning.Operations interface. Returns either an
`Operation.error` or an `Operation.response` which contains
a `LongRunningRecognizeResponse` message.
For more information on asynchronous speech recognition, see the
[how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `config` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionConfig` Required. Provides information to the recognizer that specifies how to process the request. |
| `audio` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio` Required. The audio data to be recognized. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    RecognitionConfig config = new RecognitionConfig();
    RecognitionAudio audio = new RecognitionAudio();
    // Make the request
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> response = await speechClient.LongRunningRecognizeAsync(config, audio);

    // Poll until the returned long-running operation is complete
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> completedResponse = await response.PollUntilCompletedAsync();
    // Retrieve the operation result
    LongRunningRecognizeResponse result = completedResponse.Result;

    // Or get the name of the operation
    string operationName = response.Name;
    // This name can be stored, then the long-running operation retrieved later by name
    Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> retrievedResponse = await speechClient.PollOnceLongRunningRecognizeAsync(operationName);
    // Check if the retrieved long-running operation has completed
    if (retrievedResponse.IsCompleted)
    {
        // If it has completed, then access the result
        LongRunningRecognizeResponse retrievedResult = retrievedResponse.Result;
    }

### PollOnceLongRunningRecognize(string, CallSettings)

    public virtual Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> PollOnceLongRunningRecognize(string operationName, CallSettings callSettings = null)

Poll an operation once, using an `operationName` from a previous invocation of `LongRunningRecognize`
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `operationName` | `https://learn.microsoft.com/dotnet/api/system.string` The name of a previously invoked operation. Must not be `null` or empty. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | The result of polling the operation. |

### PollOnceLongRunningRecognizeAsync(string, CallSettings)

    public virtual Task<Operation<LongRunningRecognizeResponse, LongRunningRecognizeMetadata>> PollOnceLongRunningRecognizeAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an `operationName` from a previous invocation of
`LongRunningRecognize`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `operationName` | `https://learn.microsoft.com/dotnet/api/system.string` The name of a previously invoked operation. Must not be `null` or empty. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.LongRunning/latest/Google.LongRunning.Operation-2.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeResponsehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.LongRunningRecognizeMetadata` | A task representing the result of polling the operation. |

### Recognize(RecognitionConfig, RecognitionAudio, CallSettings)

    public virtual RecognizeResponse Recognize(RecognitionConfig config, RecognitionAudio audio, CallSettings callSettings = null)

Performs synchronous speech recognition: receive results after all audio
has been sent and processed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `config` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionConfig` Required. Provides information to the recognizer that specifies how to process the request. |
| `audio` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio` Required. The audio data to be recognized. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeResponse` | The RPC response. |

**Example**

    SpeechClient client = SpeechClient.Create();
    RecognitionConfig config = new RecognitionConfig
    {
        Encoding = AudioEncoding.Linear16,
        SampleRateHertz = 16000,
        LanguageCode = LanguageCodes.English.UnitedStates
    };
    RecognizeResponse response = client.Recognize(config, audio);
    Console.WriteLine(response);

### Recognize(RecognizeRequest, CallSettings)

    public virtual RecognizeResponse Recognize(RecognizeRequest request, CallSettings callSettings = null)

Performs synchronous speech recognition: receive results after all audio
has been sent and processed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeResponse` | The RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = SpeechClient.Create();
    // Initialize request argument(s)
    RecognizeRequest request = new RecognizeRequest
    {
        Config = new RecognitionConfig(),
        Audio = new RecognitionAudio(),
    };
    // Make the request
    RecognizeResponse response = speechClient.Recognize(request);

### RecognizeAsync(RecognitionConfig, RecognitionAudio, CallSettings)

    public virtual Task<RecognizeResponse> RecognizeAsync(RecognitionConfig config, RecognitionAudio audio, CallSettings callSettings = null)

Performs synchronous speech recognition: receive results after all audio
has been sent and processed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `config` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionConfig` Required. Provides information to the recognizer that specifies how to process the request. |
| `audio` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio` Required. The audio data to be recognized. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    RecognitionConfig config = new RecognitionConfig();
    RecognitionAudio audio = new RecognitionAudio();
    // Make the request
    RecognizeResponse response = await speechClient.RecognizeAsync(config, audio);

### RecognizeAsync(RecognitionConfig, RecognitionAudio, CancellationToken)

    public virtual Task<RecognizeResponse> RecognizeAsync(RecognitionConfig config, RecognitionAudio audio, CancellationToken cancellationToken)

Performs synchronous speech recognition: receive results after all audio
has been sent and processed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `config` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionConfig` Required. Provides information to the recognizer that specifies how to process the request. |
| `audio` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio` Required. The audio data to be recognized. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    RecognitionConfig config = new RecognitionConfig();
    RecognitionAudio audio = new RecognitionAudio();
    // Make the request
    RecognizeResponse response = await speechClient.RecognizeAsync(config, audio);

### RecognizeAsync(RecognizeRequest, CallSettings)

    public virtual Task<RecognizeResponse> RecognizeAsync(RecognizeRequest request, CallSettings callSettings = null)

Performs synchronous speech recognition: receive results after all audio
has been sent and processed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    RecognizeRequest request = new RecognizeRequest
    {
        Config = new RecognitionConfig(),
        Audio = new RecognitionAudio(),
    };
    // Make the request
    RecognizeResponse response = await speechClient.RecognizeAsync(request);

### RecognizeAsync(RecognizeRequest, CancellationToken)

    public virtual Task<RecognizeResponse> RecognizeAsync(RecognizeRequest request, CancellationToken cancellationToken)

Performs synchronous speech recognition: receive results after all audio
has been sent and processed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognizeResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    SpeechClient speechClient = await SpeechClient.CreateAsync();
    // Initialize request argument(s)
    RecognizeRequest request = new RecognizeRequest
    {
        Config = new RecognitionConfig(),
        Audio = new RecognitionAudio(),
    };
    // Make the request
    RecognizeResponse response = await speechClient.RecognizeAsync(request);

### ShutdownDefaultChannelsAsync()

    public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient#Google_Cloud_Speech_V1_SpeechClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient#Google_Cloud_Speech_V1_SpeechClient_CreateAsync_System_Threading_CancellationToken_). Channels which weren't automatically created are not
affected.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task representing the asynchronous shutdown operation. |

**Remarks** After calling this method, further calls to [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient#Google_Cloud_Speech_V1_SpeechClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient#Google_Cloud_Speech_V1_SpeechClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down
by another call to this method.

### StreamingRecognize(CallSettings, BidirectionalStreamingSettings)

    public virtual SpeechClient.StreamingRecognizeStream StreamingRecognize(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Performs bidirectional streaming speech recognition: receive results while
sending audio. This method is only available via the gRPC API (not REST).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |
| `streamingSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.BidirectionalStreamingSettings.html` If not null, applies streaming overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.SpeechClient.StreamingRecognizeStream` | The client-server stream. |

**Example**

    // Create client
    SpeechClient speechClient = SpeechClient.Create();
    // Initialize streaming call, retrieving the stream object
    using SpeechClient.StreamingRecognizeStream response = speechClient.StreamingRecognize();

    // Sending requests and retrieving responses can be arbitrarily interleaved
    // Exact sequence will depend on client/server behavior

    // Create task to do something with responses from server
    Task responseHandlerTask = Task.Run(async () =>
    {
        // Note that C# 8 code can use await foreach
        AsyncResponseStream<StreamingRecognizeResponse> responseStream = response.GetResponseStream();
        while (await responseStream.MoveNextAsync())
        {
            StreamingRecognizeResponse responseItem = responseStream.Current;
            // Do something with streamed response
        }
        // The response stream has completed
    });

    // Send requests to the server
    bool done = false;
    while (!done)
    {
        // Initialize a request
        StreamingRecognizeRequest request = new StreamingRecognizeRequest
        {
            StreamingConfig = new StreamingRecognitionConfig(),
        };
        // Stream a request to the server
        await response.WriteAsync(request);
        // Set "done" to true when sending requests is complete
    }

    // Complete writing requests to the stream
    await response.WriteCompleteAsync();
    // Await the response handler
    // This will complete once all server responses have been processed
    await responseHandlerTask;