Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hands free cortana interaction
#1

hands free cortana interaction

Getting your work done by not launching the desired app is more common these days. Since every platform has its own personal assistant to get your work done as quickly as possible, why not leverage it. If you are not sure yet about what kind of personal assistant I m talking about. Well they are Cortana, Siri and Google Now. They are available in Windows, iOS and Android devices respectively. Let me talk about Cortana today and show you how you can integrate her in your own app. Cortana was introduced initially with Windows Phone 8.1 and now she is also available in Windows 10 devices (devices runs on Windows 10 OS). In Windows 10 devices, you can ask Cortana to do stuff for you. She will do the specific task and return the outcome in Cortana canvas. By the way, you can also type in the canvas to get your work done if you want to maintain privacy and of course you don t want to shout to Cortana in public every single time. You can interact with Cortana in Windows simply by saying Hey Cortana . And you will be presented with the Cortana canvas.

public sealed class VoiceCommandService : IBackgroundTask
{
private BackgroundTaskDeferral _deferral;
VoiceCommandServiceConnection _voiceServiceConnection;

public async void Run(IBackgroundTaskInstance taskInstance)
{
var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;
if (triggerDetails?.Name == "SimpleTodoVoiceCommandService")
{
_deferral = taskInstance.GetDeferral();
var cancelledTokenSource = new CancellationTokenSource();
_voiceServiceConnection =
VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails);
var voiceCommand = await _voiceServiceConnection.GetVoiceCommandAsync();

switch (voiceCommand.CommandName)
{
case "todoBackgroundCommandList":
var command =
voiceCommand.SpeechRecognitionResult.SemanticInterpretation.Properties["command"][0];
if (command == "pending")
await ShowPendingTasks();
break;

default:
LaunchAppInForeground();
break;
}

taskInstance.Canceled += (s, e) =>
{
cancelledTokenSource.Cancel();
_deferral.Complete();
};

_voiceServiceConnection.VoiceCommandCompleted += (sender, args) =>
{
cancelledTokenSource.Cancel();
_deferral.Complete();
};

_voiceServiceConnection.VoiceCommandCompleted += (sender, args) =>
{
cancelledTokenSource.Cancel();
};
}
}
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.