# Media Translation v1beta1 API - Class SpeechTranslationServiceClient (2.0.0-beta06)

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

- [2.0.0-beta06 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient)
- [2.0.0-beta05](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/2.0.0-beta05/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient)
- [1.0.0-beta03](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/1.0.0-beta03/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient)

    public abstract class SpeechTranslationServiceClient

Reference documentation and code samples for the Media Translation v1beta1 API class SpeechTranslationServiceClient.

SpeechTranslationService client wrapper, for convenient use.

## Inheritance

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

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

[SpeechTranslationServiceClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClientImpl)

## Namespace

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

## Assembly

Google.Cloud.MediaTranslation.V1Beta1.dll

## Remarks

Provides translation from/to media types.

## Properties

### DefaultEndpoint

    public static string DefaultEndpoint { get; }

The default endpoint for the SpeechTranslationService service, which is a host of
"mediatranslation.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 SpeechTranslationService 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 SpeechTranslationService scopes are:

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

<br />

### GrpcClient

    public virtual SpeechTranslationService.SpeechTranslationServiceClient GrpcClient { get; }

The underlying gRPC SpeechTranslationService client

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServicehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationService.SpeechTranslationServiceClient` |   |

### 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 SpeechTranslationServiceClient Create()

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

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

### CreateAsync(CancellationToken)

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

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

| **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.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient` | The task representing the created [SpeechTranslationServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient). |

### ShutdownDefaultChannelsAsync()

    public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient#Google_Cloud_MediaTranslation_V1Beta1_SpeechTranslationServiceClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient#Google_Cloud_MediaTranslation_V1Beta1_SpeechTranslationServiceClient_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.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient#Google_Cloud_MediaTranslation_V1Beta1_SpeechTranslationServiceClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient#Google_Cloud_MediaTranslation_V1Beta1_SpeechTranslationServiceClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down
by another call to this method.

### StreamingTranslateSpeech(CallSettings, BidirectionalStreamingSettings)

    public virtual SpeechTranslationServiceClient.StreamingTranslateSpeechStream StreamingTranslateSpeech(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)

Performs bidirectional streaming speech translation: 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.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient.StreamingTranslateSpeechStream` | The client-server stream. |

**Example**

    // Create client
    SpeechTranslationServiceClient speechTranslationServiceClient = SpeechTranslationServiceClient.Create();
    // Initialize streaming call, retrieving the stream object
    using SpeechTranslationServiceClient.StreamingTranslateSpeechStream response = speechTranslationServiceClient.StreamingTranslateSpeech();

    // 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<StreamingTranslateSpeechResponse> responseStream = response.GetResponseStream();
        while (await responseStream.MoveNextAsync())
        {
            StreamingTranslateSpeechResponse 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
        StreamingTranslateSpeechRequest request = new StreamingTranslateSpeechRequest
        {
            StreamingConfig = new StreamingTranslateSpeechConfig(),
        };
        // 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;