-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyAssisstant.cs
214 lines (163 loc) · 5.9 KB
/
MyAssisstant.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech.Synthesis;
using System.Speech.Recognition;
using System.Diagnostics;
namespace Siri
{
public partial class MyAssisstant : Form
{
bool search = false;
SpeechSynthesizer s = new SpeechSynthesizer();
SpeechRecognitionEngine reco = new SpeechRecognitionEngine();
public MyAssisstant()
{
InitializeComponent();
Choices list = new Choices();
list.Add(new string[] { "hi", "open google", "open my picture", "open you tube", "open notepad", "who is your father", "bye", "full screen", "minimize", "exit program", "search for","dog",
"open text reader","open b","what is today","what is the time"});
Grammar gm = new Grammar(new GrammarBuilder(list));
try
{
reco.RequestRecognizerUpdate();
reco.LoadGrammar(gm);
reco.SpeechRecognized += Reco_SpeechRecognized;
reco.SetInputToDefaultAudioDevice();
reco.RecognizeAsync(RecognizeMode.Multiple);
}
catch { }
}
/*private void button1_Click(object sender, EventArgs e)
{
if (button1.Enabled == true)
{
reco.RecognizeAsync(RecognizeMode.Multiple);
}
else
{
reco.RecognizeAsyncStop();
}
}*/
private void Reco_SpeechRecognized(object sender, SpeechRecognizedEventArgs e )
{
string a = e.Result.Text;
if(a=="search for")
{
search = true;
s.Speak("tell me what to search");
}
if(search)
{
string wx = e.Result.Text;
Process.Start("https://www.google.co.in/search?q=" + wx);
search = false;
}
if(a == "open text reader")
{
Form intro = new Intro();
intro.Show();
s.SpeakAsync("opening textreader");
}
if (search == false)
{
switch (a)
{
case ("hi"):
s.Speak("hello sir");
break;
case ("who is your owner"):
s.Speak("Saad Iqbal is my owner");
break;
case ("open google"):
s.Speak("opening google");
Process.Start("https://wwww.google.com");
break;
case ("open you tube"):
s.Speak("opening youtube");
Process.Start("https://www.youtube.com");
break;
case ("open my picture"):
s.Speak("opening your picture sir");
Process.Start("C:\\Users\\DLS\\Downloads\\h1.PNG");
break;
case ("open notepad"):
s.Speak("opening notepad");
Process.Start("notepad.exe");
break;
case ("bye"):
s.Speak("bye sir have nice day");
this.Close();
break;
case ("full screen"):
s.Speak("miximizing screen");
WindowState = FormWindowState.Maximized;
break;
case ("minimize"):
s.Speak("minimize screen");
WindowState = FormWindowState.Minimized;
break;
case ("exit program"):
SendKeys.Send("%{f4}");
break;
case ("open b"):
Form websearch = new websearch();
WindowState = FormWindowState.Minimized;
websearch.Show();
break;
case ("what is today"):
s.Speak("today is " + DateTime.Now.ToShortDateString());
break;
case ("what is the time"):
s.Speak("it is " + DateTime.Now.ToShortTimeString());
break;
}
}
}
private void button1_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void button1_Enter(object sender, EventArgs e)
{
}
private void gunaTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void radioButton1_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void gunaGradientButton1_Click(object sender, EventArgs e)
{
Intro obj = new Intro();
this.Hide();
obj.ShowDialog();
}
private void gunaGradientButton2_Click(object sender, EventArgs e)
{
websearch obj = new websearch();
this.Hide();
obj.ShowDialog();
}
private void gunaGradientButton3_Click(object sender, EventArgs e)
{
Form1 obj = new Form1();
this.Hide();
obj.ShowDialog();
}
private void gunaGradientButton4_Click(object sender, EventArgs e)
{
BookRead obj1 = new BookRead();
this.Hide();
obj1.ShowDialog();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}