Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
987 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to set a limit to the time a caller has to describe their problem after StartRecognizing
has started.
I tried to implement this using CancellationToken
, but it didn't work, and CancelAllMediaOperations
doesn't seem to be effective either. Here is my code:
// Configure the recognition options
var recognizeOptions = new CallMediaRecognizeSpeechOptions(caller)
{
Prompt = playSource,
EndSilenceTimeout = TimeSpan.FromMilliseconds(1000),
OperationContext = operationContext,
SpeechLanguage = "de-DE"
};
timerDebug.Start();
using (var cts = new CancellationTokenSource())
{
cts.CancelAfter(TimeSpan.FromSeconds(10));
try
{
// Start recognizing speech and return the result
StartRecognizingCallMediaResult result = await callMedia.StartRecognizingAsync(recognizeOptions, cts.Token);
result.WaitForEventProcessor(cts.Token);
}
catch(OperationCanceledException ocex)
{
logger.LogError($"RecognizeOpenQuestion() cancelled -> {ocex.Message}");
await callMedia.CancelAllMediaOperationsAsync(cts.Token);
}
catch (Exception ex)
{
logger.LogError($"RecognizeOpenQuestion() error -> {ex.Message}");
}
}
Is it possible?