Last active
July 2, 2016 05:05
-
-
Save flushpot1125/9826fff1db7559b2ead7ba574ce75328 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine.UI; | |
public class CortanaController : MonoBehaviour { | |
public GameObject botUIPanel; | |
public List<string> questions = new List<string>(); | |
public List<string> answers = new List<string>(); | |
public Text questionOptions; | |
// Use this for initialization | |
void Start() { | |
questionOptions.text = "ASK ME\n"; | |
foreach (string s in questions) { | |
questionOptions.text += s + '\n'; | |
} | |
} | |
void Update() { | |
ActiveVoiceCommand(); | |
} | |
public void ActiveVoiceCommand() { | |
Dictionary<string, string> qaList = new Dictionary<string, string>(); | |
for (int i = 0; i < questions.Count; i++) { | |
string question = questions[i]; | |
string answer = answers[i]; | |
qaList.Add(question, answer); | |
} | |
Windows10Interop.GetMeSomeVoice(qaList); | |
botUIPanel.SetActive(true); | |
} | |
// not used so far | |
public void InActiveVoiceCommand() { | |
Windows10Interop.StopVoice(); | |
botUIPanel.SetActive(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The file is based on the following sample solution. I'll appreciate such a good sample and explanation!
https://digitalerr0r.wordpress.com/2015/10/21/voice-activating-your-windows-10-games-using-speech-synthesis-voice-recognition-and-cortana/