Shuts down any channels automatically created by Create() and
CreateAsync(CancellationToken). Channels which weren't automatically created are not
affected.
A task representing the asynchronous shutdown operation.
Remarks
After calling this method, further calls to Create() and
CreateAsync(CancellationToken) will create new channels, which could in turn be shut down
by another call to this method.
// 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;
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eSpeechTranslationServiceClient\u003c/code\u003e class provides a client wrapper for the Media Translation v1beta1 API, facilitating convenient use of speech translation services.\u003c/p\u003e\n"],["\u003cp\u003eThis client allows for both synchronous and asynchronous creation via \u003ccode\u003eCreate()\u003c/code\u003e and \u003ccode\u003eCreateAsync()\u003c/code\u003e, respectively, with options for default or custom credentials, endpoints, and settings.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eStreamingTranslateSpeech\u003c/code\u003e method enables bidirectional streaming for speech translation, allowing simultaneous sending of audio and receiving of results.\u003c/p\u003e\n"],["\u003cp\u003eDefault settings for the \u003ccode\u003eSpeechTranslationServiceClient\u003c/code\u003e include a default endpoint at "mediatranslation.googleapis.com:443" and a default scope of "https://www.googleapis.com/auth/cloud-platform".\u003c/p\u003e\n"],["\u003cp\u003eIt also has a \u003ccode\u003eShutdownDefaultChannelsAsync()\u003c/code\u003e method that allows to shut down any automatically created channels, while not affecting the ones that were not automatically generated.\u003c/p\u003e\n"]]],[],null,["# Media Translation v1beta1 API - Class SpeechTranslationServiceClient (2.0.0-beta05)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0-beta05 (latest)](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient)\n- [2.0.0-beta04](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/2.0.0-beta04/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient)\n- [1.0.0-beta03](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/1.0.0-beta03/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient) \n\n public abstract class SpeechTranslationServiceClient\n\nReference documentation and code samples for the Media Translation v1beta1 API class SpeechTranslationServiceClient.\n\nSpeechTranslationService client wrapper, for convenient use. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e SpeechTranslationServiceClient \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring) \n\nDerived Types\n-------------\n\n[SpeechTranslationServiceClientImpl](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClientImpl)\n\nNamespace\n---------\n\n[Google.Cloud.MediaTranslation.V1Beta1](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1)\n\nAssembly\n--------\n\nGoogle.Cloud.MediaTranslation.V1Beta1.dll\n\nRemarks\n-------\n\nProvides translation from/to media types.\n\nProperties\n----------\n\n### DefaultEndpoint\n\n public static string DefaultEndpoint { get; }\n\nThe default endpoint for the SpeechTranslationService service, which is a host of\n\"mediatranslation.googleapis.com\" and a port of 443.\n\n### DefaultScopes\n\n public static IReadOnlyList\u003cstring\u003e DefaultScopes { get; }\n\nThe default SpeechTranslationService scopes.\n\n**Remarks** \nThe default SpeechTranslationService scopes are:\n\n- \u003chttps://www.googleapis.com/auth/cloud-platform\u003e\n\n\u003cbr /\u003e\n\n### GrpcClient\n\n public virtual SpeechTranslationService.SpeechTranslationServiceClient GrpcClient { get; }\n\nThe underlying gRPC SpeechTranslationService client\n\n### ServiceMetadata\n\n public static ServiceMetadata ServiceMetadata { get; }\n\nThe service metadata associated with this client type.\n\nMethods\n-------\n\n### Create()\n\n public static SpeechTranslationServiceClient Create()\n\nSynchronously creates a [SpeechTranslationServiceClient](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient) using the default credentials, endpoint\nand settings. To specify custom credentials or other settings, use\n[SpeechTranslationServiceClientBuilder](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClientBuilder).\n\n### CreateAsync(CancellationToken)\n\n public static Task\u003cSpeechTranslationServiceClient\u003e CreateAsync(CancellationToken cancellationToken = default)\n\nAsynchronously creates a [SpeechTranslationServiceClient](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient) using the default credentials,\nendpoint and settings. To specify custom credentials or other settings, use\n[SpeechTranslationServiceClientBuilder](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClientBuilder).\n\n### ShutdownDefaultChannelsAsync()\n\n public static Task ShutdownDefaultChannelsAsync()\n\nShuts down any channels automatically created by [Create()](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient#Google_Cloud_MediaTranslation_V1Beta1_SpeechTranslationServiceClient_Create) and\n[CreateAsync(CancellationToken)](/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\naffected.\n\n**Remarks** \nAfter calling this method, further calls to [Create()](/dotnet/docs/reference/Google.Cloud.MediaTranslation.V1Beta1/latest/Google.Cloud.MediaTranslation.V1Beta1.SpeechTranslationServiceClient#Google_Cloud_MediaTranslation_V1Beta1_SpeechTranslationServiceClient_Create) and\n[CreateAsync(CancellationToken)](/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\nby another call to this method.\n\n### StreamingTranslateSpeech(CallSettings, BidirectionalStreamingSettings)\n\n public virtual SpeechTranslationServiceClient.StreamingTranslateSpeechStream StreamingTranslateSpeech(CallSettings callSettings = null, BidirectionalStreamingSettings streamingSettings = null)\n\nPerforms bidirectional streaming speech translation: receive results while\nsending audio. This method is only available via the gRPC API (not REST).\n\n**Example** \n\n // Create client\n SpeechTranslationServiceClient speechTranslationServiceClient = SpeechTranslationServiceClient.Create();\n // Initialize streaming call, retrieving the stream object\n using SpeechTranslationServiceClient.StreamingTranslateSpeechStream response = speechTranslationServiceClient.StreamingTranslateSpeech();\n\n // Sending requests and retrieving responses can be arbitrarily interleaved\n // Exact sequence will depend on client/server behavior\n\n // Create task to do something with responses from server\n Task responseHandlerTask = Task.Run(async () =\u003e\n {\n // Note that C# 8 code can use await foreach\n AsyncResponseStream\u003cStreamingTranslateSpeechResponse\u003e responseStream = response.GetResponseStream();\n while (await responseStream.MoveNextAsync())\n {\n StreamingTranslateSpeechResponse responseItem = responseStream.Current;\n // Do something with streamed response\n }\n // The response stream has completed\n });\n\n // Send requests to the server\n bool done = false;\n while (!done)\n {\n // Initialize a request\n StreamingTranslateSpeechRequest request = new StreamingTranslateSpeechRequest\n {\n StreamingConfig = new StreamingTranslateSpeechConfig(),\n };\n // Stream a request to the server\n await response.WriteAsync(request);\n // Set \"done\" to true when sending requests is complete\n }\n\n // Complete writing requests to the stream\n await response.WriteCompleteAsync();\n // Await the response handler\n // This will complete once all server responses have been processed\n await responseHandlerTask;"]]