Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK v1.13 draft: add KeywordRecognizer support to UWP VA #500

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions clients/csharp-uwp/UWPVoiceAssistantSample/ActivityWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace UWPVoiceAssistantSample
{
using Newtonsoft.Json.Linq;

using Newtonsoft.Json.Linq;
/// <summary>
/// Class determines the activity received from the Bot and deserializes the response.
/// </summary>
Expand All @@ -18,31 +18,31 @@ public ActivityWrapper(string activityJson)
{
var activityObj = JObject.Parse(activityJson);

switch (activityObj["type"]?.ToString().ToLower())
switch (activityObj["type"]?.ToString().ToUpperInvariant())
{
case "trace":
case "TRACE":
this.Type = ActivityType.Trace;
break;
case "message":
case "MESSAGE":
this.Type = ActivityType.Message;
break;
case "event":
case "EVENT":
this.Type = ActivityType.Event;
break;
default:
this.Type = ActivityType.Unrecognized;
break;
}

switch (activityObj["inputHint"]?.ToString().ToLower())
switch (activityObj["inputHint"]?.ToString().ToUpperInvariant())
{
case "ignoringinput":
case "IGNORINGINPUT":
this.InputHint = InputHintType.IgnoringInput;
break;
case "acceptinginput":
case "ACCEPTINGINPUT":
this.InputHint = InputHintType.AcceptingInput;
break;
case "expectinginput":
case "EXPECTINGINPUT":
this.InputHint = InputHintType.ExpectingInput;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AgentSessionManager()
/// <summary>
/// Gets a value indicating whether this object has already processed a Dispose() call.
/// </summary>
protected bool AlreadyDisposed { get; private set; } = false;
protected bool AlreadyDisposed { get; private set; }

/// <summary>
/// It's not required, but for optimization purposes it's acceptable to cache the ConversationalAgentSession
Expand Down
12 changes: 5 additions & 7 deletions clients/csharp-uwp/UWPVoiceAssistantSample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public sealed partial class App : Application, IDisposable
{
private readonly ILogProvider logger;
private readonly IDialogManager dialogManager;
private readonly IKeywordRegistration keywordRegistration;
private readonly IAgentSessionManager agentSessionManager;
private BackgroundTaskDeferral deferral;
private bool alreadyDisposed = false;
private bool alreadyDisposed;

/// <summary>
/// Initializes a new instance of the <see cref="App"/> class.
Expand All @@ -45,21 +46,18 @@ public App()
this.Suspending += this.OnSuspending;
MVARegistrationHelpers.UnlockLimitedAccessFeature();

var keywordRegistration = new KeywordRegistration(
new Version(1, 0, 0, 0));

this.keywordRegistration = new KeywordRegistration();
this.agentSessionManager = new AgentSessionManager();

this.dialogManager = new DialogManager<List<byte>>(
new DirectLineSpeechDialogBackend(),
keywordRegistration,
this.keywordRegistration,
new AgentAudioInputProvider(),
this.agentSessionManager,
new MediaPlayerDialogAudioOutputAdapter());

var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton(this.dialogManager);
serviceCollection.AddSingleton<IKeywordRegistration>(keywordRegistration);
serviceCollection.AddSingleton(this.keywordRegistration);
serviceCollection.AddSingleton(this.agentSessionManager);
this.Services = serviceCollection.BuildServiceProvider();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public enum WaveHeaderLengthOption
/// <summary>
/// An encapsulation of extra data and operations needed to apply a WAVEFORMAT header to an existing stream.
/// </summary>
public class WaveHeader
public static class WaveHeader
{
/// <summary>
/// Writes a standard WAVEFORMAT header (RIFF) to the provided stream that matches the provided PCM encoding
Expand Down
Loading