Skip to content
Open
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
1,038 changes: 1,038 additions & 0 deletions Assets/Samples/6 - Voice Commands/6 - Voice Commands.unity

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions Assets/Samples/6 - Voice Commands/VoiceCommandsDemo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class VoiceCommandsDemo : MonoBehaviour
{
public VoiceCommandsManager VC;

public delegate void thenDoDelegate(string command);

public Text resultText;

// Start is called before the first frame update
void Start()
{
RegisterCommands();

}

public void RegisterCommands()
{
VC.RegisterCommand("Try saying this!", (thenDoDelegate)thenDoA);
VC.RegisterCommand("Here's my choice.", (thenDoDelegate)thenDoB);
VC.RegisterCommand("Where am I?", (thenDoDelegate)thenDoC);
}

public void thenDoA(string command)
{
resultText.text += "You said \""+command+"\"\n";

VC?.UnregisterAll();//Unregistering is also important to clear transcription.

RegisterCommands();
}

public void thenDoB(string command)
{
resultText.text += "You said \"" + command + "\"\n";

VC?.UnregisterAll();//Unregistering is also important to clear transcription.

VC.RegisterCommand("I'll have some eggs and bacon", (thenDoDelegate)thenDoA);
VC.RegisterCommand("Not hungry, thanks.", (thenDoDelegate)thenDoA);
}

public void thenDoC(string command)
{
resultText.text += "You said \"" + command + "\"\n";

VC?.UnregisterAll();//Unregistering is also important to clear transcription.

//capitalizaiton and punctuation are totally forgiving...
VC.RegisterCommand("oh i remember now... I'm SITTING at my desk!", (thenDoDelegate)thenDoA);
}
}
11 changes: 11 additions & 0 deletions Assets/Samples/6 - Voice Commands/VoiceCommandsDemo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading