Skip to content

Commit

Permalink
Added Text To speech #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Gr8z committed May 20, 2017
1 parent b1d0d48 commit d1c1135
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 26 deletions.
10 changes: 6 additions & 4 deletions ChatBotProject/ChatBotProject/ChatBot.Designer.cs

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

17 changes: 16 additions & 1 deletion ChatBotProject/ChatBotProject/ChatBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows.Forms;
using System.Media;
using System.IO; // needed for filing
using System.Speech.Synthesis;

namespace ChatBotProject
{
Expand All @@ -13,6 +14,9 @@ public Form1()
}

static ChatBot bot;
SpeechSynthesizer reader = new SpeechSynthesizer();
bool textToSpeech = false;

private void Form1_Load(object sender, EventArgs e)
{
bot = new ChatBot();
Expand Down Expand Up @@ -79,7 +83,7 @@ private void showOutput()
var t = new Timer();

// Time in milseconds - minimum delay of 1s plus 0.1s per character.
t.Interval = 1; // 1000 + (outtt.Length * 100);
t.Interval = 1000 + (outtt.Length * 100);

// Show the "Bot is typing.." text
txtTyping.Show();
Expand All @@ -99,6 +103,12 @@ private void showOutput()
// Show the bot message and play the sound
addOutMessage(outtt);
Rcv.Play();

// Text to Speech if enabled
if (textToSpeech)
{
reader.SpeakAsync(outtt);
}

InputTxt.Focus(); // Put the cursor back on the textbox
t.Stop();
Expand Down Expand Up @@ -196,5 +206,10 @@ private void menuButton_Click(object sender, EventArgs e)
contextMenuStrip1.Show(menuButton, new System.Drawing.Point(0, -contextMenuStrip1.Size.Height));
}

private void toggleVoiceToolStripMenuItem_Click(object sender, EventArgs e)
{
// whenever the toggle is clicked, true is set to false visa versa.
textToSpeech = !textToSpeech;
}
}
}
42 changes: 21 additions & 21 deletions ChatBotProject/ChatBotProject/ChatBot.resx
Original file line number Diff line number Diff line change
Expand Up @@ -288,27 +288,6 @@
<metadata name="bunifuElipse1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>177, 17</value>
</metadata>
<data name="menuButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1
MAAA6mAAADqYAAAXcJy6UTwAAAAJcEhZcwAACxMAAAsTAQCanBgAAANPSURBVHhe7dyhbUBRDATBNP3r
TxpY8KSY3YAhyywd9s/3fTArI6zICCsywoqMsCIjrMgIKzLCioywIiOsyAgrMsKKjLAiI6zICCsywoqM
sCIjrMgIKzLCioywIiOsyAgrMsKKjLAiI6zICCsywoqMsCIjrMgIKzLCioywIiOsyAgrMsKKjLAiI6zI
CCsywoqMsCIjrMgIKzLCioywIiOsyAgrMsKKjMd+4R9qU2cyHquj4FVt6kzGY3UUvKpNncl4rI6CV7Wp
MxmP1VHwqjZ1JuOxOgpe1abOZDxWR8Gr2tSZjMfqKHhVmzqT8VgdBa9qU2cyHquj4FVt6kzGY3UUvKpN
ncl4rI6CV7WpMxmP1VHwqjZ1JuOxOgpe1abOZDxWR8Gr2tSZjMfqKHhVmzqTEVZkhBUZYUVGWJERVmSE
FRlhRUZYkRFWZIQVGWFFRliREVZkhBUZYUVGWJERVmSEFRlhRUZYkRFWZIQVGWFFRliR8Vg9O4JXtakz
GY/VUfCqNnUm47E6Cl7Vps5kPFZHwava1JmMx+ooeFWbOpPxWB0Fr2pTZzIeq6PgVW3qTMZjdRS8qk2d
yXisjoJXtakzGY/VUfCqNnUm47E6Cl7Vps5kPFZHwava1JmMx+ooeFWbOpPxWB0Fr2pTZzIeq6PgVW3q
TMZjdRS8qk2dyQgrMsKKjLAiI6zICCsywoqMsCIjrMgIKzLCioywIiOsyAgrMsKKjLAiI6zICCsywoqM
sCIjrMgIKzLCioywIiOsyHisnh3Bq9rUmYzH6ih4VZs6k/FYHQWvalNnMh6ro+BVbepMxmN1FLyqTZ3J
eKyOgle1qTMZj9VR8Ko2dSbjsToKXtWmzmQ8VkfBq9rUmYzH6ih4VZs6k/FYHQWvalNnMh6ro+BVbepM
xmN1FLyqTZ3JeKyOgle1qTMZj9VR8Ko2dSbjsToKXtWmzmSEFRlhRUZYkRFWZIQVGWFFRliREVZkhBUZ
YUVGWJERVmSEFRlhRUZYkRFWZIQVGWFFRliREVZkhBUZYUVGWJERVmSEFRlhRUZYkRFWZIQVGWFFRliR
EVZkhBUZYUVGWJERVmSEFRlhRUZYkRFWZIQVGWFFRliREVZkhBUZYUVGWJERNnw/f+slYiGpbk4GAAAA
AElFTkSuQmCC
</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAYAEBAAAAEAIABoBAAAZgAAACAgAAABACAAqBAAAM4EAAAwMAAAAQAgAKglAAB2FQAAQEAAAAEA
Expand Down Expand Up @@ -2073,6 +2052,27 @@
NuAXwP1Asxc2yEs3AzUDXwEeAW4AVgIzgQogpLojBWgQZ4Vfs3uS+y3wOpD2ygaOagAYA/FECmNO+k/S
bvdoI/B9NwBmAQ1ABN0/kOXyMKQzNuYUBSLDYuPc2HMI2OUGQOdpf8k2jHZRjGoAzJs+hmsvmY5lndEw
v9P92aD6lEOWJl08kxq2Yd70MaP6nf8HFqy2XDeBwhMAAAAASUVORK5CYII=
</value>
</data>
<data name="menuButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1
MAAA6mAAADqYAAAXcJy6UTwAAAAJcEhZcwAACxMAAAsTAQCanBgAAANPSURBVHhe7dyhbUBRDATBNP3r
TxpY8KSY3YAhyywd9s/3fTArI6zICCsywoqMsCIjrMgIKzLCioywIiOsyAgrMsKK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AAA
AElFTkSuQmCC
</value>
</data>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Expand Down
Binary file not shown.

0 comments on commit d1c1135

Please sign in to comment.