Click or drag to resize
SpeechClientRecognizeAsync Method
Streams audio asynchronously to the speech service for recognition.

Namespace:  Microsoft.Bing.Speech
Assembly:  Microsoft.Bing.Speech (in Microsoft.Bing.Speech.dll) Version: 2.0.1.0 (2.0.1)
Syntax
public Task RecognizeAsync(
	SpeechInput speechInput,
	CancellationToken token
)

Parameters

speechInput
Type: Microsoft.Bing.SpeechSpeechInput
The speech service input parameters.
token
Type: System.ThreadingCancellationToken
The cancellation token used to cancel your request at any time, or to set a request time out.

Return Value

Type: Task
A task that completes once the request completes. In ShortPhrase mode, the task completes after getting the RecognitionResult. In LongDictation mode, the task completes after the final RecognitionResult.

Implements

ISpeechClientRecognizeAsync(SpeechInput, CancellationToken)
Exceptions
ExceptionCondition
ArgumentNullExceptionSpeech input or one of its members was null.
NotSupportedExceptionAudio stream was not readable.
InvalidOperationExceptionAnother recognition is in progress.
ArgumentOutOfRangeExceptionFailed to read any bytes from the stream.
ArgumentExceptionAudio stream was null.
ClientExceptionRecognition failed due a client side problem.
ServerExceptionRecognition failed due a server side problem.
ObjectDisposedExceptionClient was already disposed.
Remarks
The API utilizes a single websocket connection per request. For optimal user experience, the API will attempt to reconnect to the speech service and start the recognition from the last RecognitionResult. For example, consider a two minutes long audio, after successfully streaming for a minute, and some network interruption occurs, the API will resend any audio it did not receive a successful RecognitionResult for.

Note: the API keeps internal buffer for such cases.

Examples
var task = speechClient.RecognizeAsync(speechInput, cancellationToken);
See Also