[ VB.NET ] Speech to text vb.net

تم تحميل الصفحة في 0,1441876 ثانية
Speech to text vb.net

Egy Pro Hack

Beginner Developer
rank
إنضم
24 سبتمبر 2015
المشاركات
28
الإعجابات
7
النقاط
3
السلام عليكم شباب ..
عساكم بخير دوماً .
الحين ابغي ( سورس/كود/مشروع/شرح )
لتنفيذ التالي :
لو تحدثت في المايك عندي بكتب كل ما تحدثته في Text box
مثلاً لما اتكلم واقول
Hi
يكتب في تكست بوكس
Hi
لما اتكلم و اقول 5 ( ارقام )
يكتب في التكست بوكس
5
وهكذا ..
وشكراً مقدماً
 

Ahmed Al'jabari

إداري أقسام البرمجة
rankrankrankrank
إنضم
24 يونيو 2017
المشاركات
1,423
الإعجابات
1,130
النقاط
123
الإقامة
Turkey

كود:
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;
using System.Speech.Recognition;
using System.Threading;
 
 
namespace Speech_To_Text
{
    public partial class Form1 : Form
    {
        public SpeechRecognitionEngine recognizer;
 
        public Grammar grammar;
 
        public Thread RecThread;
        public Boolean RecognizerState = true;
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            //Here we first need to setup the grammar rules:
 
            GrammarBuilder build = new GrammarBuilder();
            build.AppendDictation();
 
            grammar = new Grammar(build);
 
            //In here we initialize the recognizer and setup its events:
 
            recognizer = new SpeechRecognitionEngine();
            recognizer.LoadGrammar(grammar);
            recognizer.SetInputToDefaultAudioDevice();
 
            recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
 
            //Here will initialize the recognizer thread:
 
            RecognizerState = true;
            RecThread = new Thread(new ThreadStart(RecThreadFunction));
            RecThread.Start();
 
 
 
        }
        public void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //Recognizer recognizes the speech
 
            if (!RecognizerState)
                return;
 
            this.Invoke((MethodInvoker)delegate
            {
                textBox1.Text += (" " + e.Result.Text.ToLower());
                //This will add a space between each word you say
            });
        }
        public void RecThreadFunction()
        {
            //This is on separate threads. Will loop the recognizer when receiving calls
      
            while (true)
            {
                try
                {
                    recognizer.Recognize();
                }
                catch
                {
                    //Handles errors
                    //Won't hear you, nothing will happen
                }
            }
      
      
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            RecognizerState = true;
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            RecognizerState = false;
        }
 
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            RecThread.Abort();
            RecThread = null;
 
            recognizer.UnloadAllGrammars();
            recognizer.Dispose();
 
            grammar = null;
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            //Searches google for textbox result using your default browser.
            System.Diagnostics.Process.Start("https://www.google.com/#q=" + (textBox1.Text));
        }
    }
}
 
إنضم
24 سبتمبر 2015
المشاركات
28
الإعجابات
7
النقاط
3

كود:
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;
using System.Speech.Recognition;
using System.Threading;


namespace Speech_To_Text
{
    public partial class Form1 : Form
    {
        public SpeechRecognitionEngine recognizer;

        public Grammar grammar;

        public Thread RecThread;
        public Boolean RecognizerState = true;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //Here we first need to setup the grammar rules:

            GrammarBuilder build = new GrammarBuilder();
            build.AppendDictation();

            grammar = new Grammar(build);

            //In here we initialize the recognizer and setup its events:

            recognizer = new SpeechRecognitionEngine();
            recognizer.LoadGrammar(grammar);
            recognizer.SetInputToDefaultAudioDevice();

            recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

            //Here will initialize the recognizer thread:

            RecognizerState = true;
            RecThread = new Thread(new ThreadStart(RecThreadFunction));
            RecThread.Start();



        }
        public void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //Recognizer recognizes the speech

            if (!RecognizerState)
                return;

            this.Invoke((MethodInvoker)delegate
            {
                textBox1.Text += (" " + e.Result.Text.ToLower());
                //This will add a space between each word you say
            });
        }
        public void RecThreadFunction()
        {
            //This is on separate threads. Will loop the recognizer when receiving calls
     
            while (true)
            {
                try
                {
                    recognizer.Recognize();
                }
                catch
                {
                    //Handles errors
                    //Won't hear you, nothing will happen
                }
            }
     
     
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RecognizerState = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RecognizerState = false;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            RecThread.Abort();
            RecThread = null;

            recognizer.UnloadAllGrammars();
            recognizer.Dispose();

            grammar = null;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //Searches google for textbox result using your default browser.
            System.Diagnostics.Process.Start("https://www.google.com/#q=" + (textBox1.Text));
        }
    }
}

كود:
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;
using System.Speech.Recognition;
using System.Threading;


namespace Speech_To_Text
{
    public partial class Form1 : Form
    {
        public SpeechRecognitionEngine recognizer;

        public Grammar grammar;

        public Thread RecThread;
        public Boolean RecognizerState = true;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //Here we first need to setup the grammar rules:

            GrammarBuilder build = new GrammarBuilder();
            build.AppendDictation();

            grammar = new Grammar(build);

            //In here we initialize the recognizer and setup its events:

            recognizer = new SpeechRecognitionEngine();
            recognizer.LoadGrammar(grammar);
            recognizer.SetInputToDefaultAudioDevice();

            recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

            //Here will initialize the recognizer thread:

            RecognizerState = true;
            RecThread = new Thread(new ThreadStart(RecThreadFunction));
            RecThread.Start();



        }
        public void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //Recognizer recognizes the speech

            if (!RecognizerState)
                return;

            this.Invoke((MethodInvoker)delegate
            {
                textBox1.Text += (" " + e.Result.Text.ToLower());
                //This will add a space between each word you say
            });
        }
        public void RecThreadFunction()
        {
            //This is on separate threads. Will loop the recognizer when receiving calls
     
            while (true)
            {
                try
                {
                    recognizer.Recognize();
                }
                catch
                {
                    //Handles errors
                    //Won't hear you, nothing will happen
                }
            }
     
     
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RecognizerState = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RecognizerState = false;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            RecThread.Abort();
            RecThread = null;

            recognizer.UnloadAllGrammars();
            recognizer.Dispose();

            grammar = null;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //Searches google for textbox result using your default browser.
            System.Diagnostics.Process.Start("https://www.google.com/#q=" + (textBox1.Text));
        }
    }
}

كود:
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;
using System.Speech.Recognition;
using System.Threading;


namespace Speech_To_Text
{
    public partial class Form1 : Form
    {
        public SpeechRecognitionEngine recognizer;

        public Grammar grammar;

        public Thread RecThread;
        public Boolean RecognizerState = true;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //Here we first need to setup the grammar rules:

            GrammarBuilder build = new GrammarBuilder();
            build.AppendDictation();

            grammar = new Grammar(build);

            //In here we initialize the recognizer and setup its events:

            recognizer = new SpeechRecognitionEngine();
            recognizer.LoadGrammar(grammar);
            recognizer.SetInputToDefaultAudioDevice();

            recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

            //Here will initialize the recognizer thread:

            RecognizerState = true;
            RecThread = new Thread(new ThreadStart(RecThreadFunction));
            RecThread.Start();



        }
        public void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //Recognizer recognizes the speech

            if (!RecognizerState)
                return;

            this.Invoke((MethodInvoker)delegate
            {
                textBox1.Text += (" " + e.Result.Text.ToLower());
                //This will add a space between each word you say
            });
        }
        public void RecThreadFunction()
        {
            //This is on separate threads. Will loop the recognizer when receiving calls
     
            while (true)
            {
                try
                {
                    recognizer.Recognize();
                }
                catch
                {
                    //Handles errors
                    //Won't hear you, nothing will happen
                }
            }
     
     
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RecognizerState = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RecognizerState = false;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            RecThread.Abort();
            RecThread = null;

            recognizer.UnloadAllGrammars();
            recognizer.Dispose();

            grammar = null;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //Searches google for textbox result using your default browser.
            System.Diagnostics.Process.Start("https://www.google.com/#q=" + (textBox1.Text));
        }
    }
}
شكراً لمشاركتك لكن عندما انطق رقم 1 بالانجليزي
اقول One
يكتب ONE
اقول Two يكتب The
يعالج رقم 1 و 5 فقط كما في الصورة عدة ارقاام
 

Ahmed Al'jabari

إداري أقسام البرمجة
rankrankrankrank
إنضم
24 يونيو 2017
المشاركات
1,423
الإعجابات
1,130
النقاط
123
الإقامة
Turkey
شكراً لمشاركتك لكن عندما انطق رقم 1 بالانجليزي
اقول One
يكتب ONE
اقول Two يكتب The
يعالج رقم 1 و 5 فقط كما في الصورة عدة ارقاام
ممكن يكون لفضك للحرف خاطئ
 

الأعضاء النشطين حاليآ الذين يشاهدون هذا الموضوع (1 عضو و 0 ضيف)

خيارات الاستايل

نوع الخط
مودك
اخفاء السايدر بار OFF
توسيط المنتدى OFF
فصل الأقسام OFF
الأقسام الفرعية OFF
عرض المشاركات
حجم الخط
معلومات العضو OFF
إخفاء التوقيع OFF

إرجاع خيارات الإستايل