this project about say the name of the site u need to visit it and the browser go to the destination
the code by C#
at first we need to add
using System.Speech.Recognition;
using System.Speech.Synthesis;
to the code to enable it
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.Recognition;
using System.Speech.Synthesis;
using System.Threading;
namespace webenginbysound
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SpeechSynthesizer sSyn = new SpeechSynthesizer();
PromptBuilder pBuilder = new PromptBuilder();
SpeechRecognitionEngine sRecognition = new SpeechRecognitionEngine();
private void toolStripButton2_Click(object sender, EventArgs e)
{
/************************************************
* text to speech
pBuilder.ClearContent();
pBuilder.AppendText(toolStripTextBox1.Text);
sSyn.Speak(pBuilder);
**************************************************/
Choices sList = new Choices();
sList.Add(new string[] { "google", "yahoo", "facebook", "twitter", "Exit" });
Grammar gRamer = new Grammar(new GrammarBuilder(sList));
try
{
sRecognition.RequestRecognizerUpdate();
sRecognition.LoadGrammar(gRamer);
sRecognition.SpeechRecognized +=sRecognition_SpeechRecognized;
sRecognition.SetInputToDefaultAudioDevice();
sRecognition.RecognizeAsync(RecognizeMode.Multiple);
}
catch
{
return;
}
}
private void sRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "Exit")
Application.Exit();
else
toolStripTextBox1.Text = e.Result.Text.ToString()+".com";
// that 's the result and i but .com to make acces to the search easy way
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(toolStripTextBox1.Text);
}
}
}
If we need to add more than word we can do it by add
sList.Add(new string[] { "google", "yahoo", "facebook", "twitter", "Exit" });
to this line the words
this is the code for go in browser
webBrowser1.Navigate(toolStripTextBox1.Text);
if we need it run after we speak directly
we can put it in the
private void sRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
the code by C#
at first we need to add
using System.Speech.Recognition;
using System.Speech.Synthesis;
to the code to enable it
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.Recognition;
using System.Speech.Synthesis;
using System.Threading;
namespace webenginbysound
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SpeechSynthesizer sSyn = new SpeechSynthesizer();
PromptBuilder pBuilder = new PromptBuilder();
SpeechRecognitionEngine sRecognition = new SpeechRecognitionEngine();
private void toolStripButton2_Click(object sender, EventArgs e)
{
/************************************************
* text to speech
pBuilder.ClearContent();
pBuilder.AppendText(toolStripTextBox1.Text);
sSyn.Speak(pBuilder);
**************************************************/
Choices sList = new Choices();
sList.Add(new string[] { "google", "yahoo", "facebook", "twitter", "Exit" });
Grammar gRamer = new Grammar(new GrammarBuilder(sList));
try
{
sRecognition.RequestRecognizerUpdate();
sRecognition.LoadGrammar(gRamer);
sRecognition.SpeechRecognized +=sRecognition_SpeechRecognized;
sRecognition.SetInputToDefaultAudioDevice();
sRecognition.RecognizeAsync(RecognizeMode.Multiple);
}
catch
{
return;
}
}
private void sRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "Exit")
Application.Exit();
else
toolStripTextBox1.Text = e.Result.Text.ToString()+".com";
// that 's the result and i but .com to make acces to the search easy way
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(toolStripTextBox1.Text);
}
}
}
If we need to add more than word we can do it by add
sList.Add(new string[] { "google", "yahoo", "facebook", "twitter", "Exit" });
to this line the words
this is the code for go in browser
webBrowser1.Navigate(toolStripTextBox1.Text);
if we need it run after we speak directly
we can put it in the
private void sRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
if i need the code to read the web site name i can use this code
pBuilder.ClearContent();
pBuilder.AppendText(toolStripTextBox1.Text);
sSyn.Speak(pBuilder);
this will be the function to read the site
string addrese="";
private void sRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "Exit")
Application.Exit();
else
toolStripTextBox1.Text = e.Result.Text.ToString()+".com";
if (Convert.ToString(toolStripTextBox1.Text) != addrese)
{
pBuilder.ClearContent();
pBuilder.AppendText(toolStripTextBox1.Text);
sSyn.Speak(pBuilder);
webBrowser1.Navigate(toolStripTextBox1.Text);
}
addrese = Convert.ToString(toolStripTextBox1.Text);
}
this will be the function to read the site
string addrese="";
private void sRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "Exit")
Application.Exit();
else
toolStripTextBox1.Text = e.Result.Text.ToString()+".com";
if (Convert.ToString(toolStripTextBox1.Text) != addrese)
{
pBuilder.ClearContent();
pBuilder.AppendText(toolStripTextBox1.Text);
sSyn.Speak(pBuilder);
webBrowser1.Navigate(toolStripTextBox1.Text);
}
addrese = Convert.ToString(toolStripTextBox1.Text);
}
the project
http://multiupload.biz/8ty3vtqc30as/webenginbysound_MultiUpload.biz.rar.html
download projecthttp://multiupload.biz/8ty3vtqc30as/webenginbysound_MultiUpload.biz.rar.html
ليست هناك تعليقات:
إرسال تعليق