Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active July 2, 2016 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/9826fff1db7559b2ead7ba574ce75328 to your computer and use it in GitHub Desktop.
Save flushpot1125/9826fff1db7559b2ead7ba574ce75328 to your computer and use it in GitHub Desktop.
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);
}
}
@flushpot1125
Copy link
Author

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment