-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecongnition.cs
145 lines (130 loc) · 3.24 KB
/
Recongnition.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System.Collections;
using System.Linq;
using UnityEngine.Windows.Speech;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Text.RegularExpressions;
public class Recongnition : MonoBehaviour {
KeywordRecognizer keywordrecognizer;
Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
public float timing = 0;
public bool test = false;
public bool drama = false;
public bool sports = false;
public bool hunt = false;
public bool cfa = false;
public bool hamerschlag = false;
public bool stop = false;
public List<Dictionary<string,object>> data = new List<Dictionary<string, object>>();
public bool dataTest = false;
CharacterController controller;
Move move;
// Use this for initialization
void Start() {
controller = GetComponent<CharacterController>();
move = controller.GetComponent<Move>();
keywords.Add("start", () => {
//data = CSVReader.Read ("unityTest.csv");
dataTest=true;
});
keywords.Add("up", () =>
{
test = true;
});
keywords.Add("go to drama", () =>
{
drama = true;
});
keywords.Add("go to sports field", () =>
{
sports = true;
});
keywords.Add("go to hunt", () =>
{
hunt = true;
});
keywords.Add("go to CFA", () =>
{
cfa = true;
});
keywords.Add("go to Hamerschlag", () =>
{
hamerschlag = true;
});
keywords.Add("sixteen one hundred", () =>
{
hunt = true;
});
keywords.Add("critical theories in art", () =>
{
cfa = true;
});
keywords.Add("do some sports", () =>
{
sports = true;
});
keywords.Add("go to functional programming class", () =>
{
hamerschlag = true;
});
keywords.Add("stop", () =>
{
stop = true;
});
keywordrecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
keywordrecognizer.OnPhraseRecognized += keywordrecognizeronphraserecoginized;
keywordrecognizer.Start();
}
void keywordrecognizeronphraserecoginized(PhraseRecognizedEventArgs args)
{
System.Action keywordAction;
if (keywords.TryGetValue(args.text, out keywordAction))
{
keywordAction.Invoke();
}
}
// Update is called once per frame
void Update () {
if (dataTest) {
//Debug.Log("call success");
//Debug.Log(data[0]["Course Number"]);
dataTest = false;
}
if (test)
{
//Debug.Log("Hear test");
test = false;
}
if (drama)
{
move.destination = 3;
drama = false;
}
if (sports)
{
move.destination = 16;
sports = false;
}
if (hamerschlag)
{
move.destination = 22;
hamerschlag = false;
}
if (cfa)
{
move.destination = 11;
cfa = false;
}
if (hunt)
{
move.destination = 9;
hunt = false;
}
if (stop)
{
move.stop();
stop = false;
}
}
}