Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am try to find Speech to text as we speak and type or speak in Google translate, we speak in English language and it gets converted and written in Hindi on the second screen in ASP.NET C# and .NET Core.

What I have tried:

C#
using System;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech.Recognition;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Globalization;
using System.Speech.Synthesis;

namespace WindowsFormSpeechtotext
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

               private void Form1_Load(object sender, EventArgs e)
        {            
            SpeechRecognitionEngine speechRecognition =
                new SpeechRecognitionEngine
                    (new System.Globalization.CultureInfo("en-US"));          

           speechRecognition.SetInputToDefaultAudioDevice();          

          Grammar grammar = new DictationGrammar();
                     speechRecognition.LoadGrammar(grammar);

            speechRecognition.SpeechRecognized +=
                new EventHandler<SpeechRecognizedEventArgs> 
                (SpeechRecognition_SpeechRecognized);
            //
            speechRecognition.RecognizeAsync(RecognizeMode.Multiple);     
        }
        
        private void SpeechRecognition_SpeechRecognized
                (object sender, SpeechRecognizedEventArgs e)
        {
            richTextBox1.Text += e.Result.Text + "\r\n";
        }

This is not work for accuracy speech. It recognizes speech.
Posted
Updated 14-Sep-23 8:25am
v4
Comments
Andre Oosthuizen 21-Aug-23 4:28am    
Quote: This is not work - what is not working? Are there any errors? Where are the errors? What is teh outcome (show example) that you need compared to what you currently get (show example)?
ArvindTomar 21-Aug-23 14:56pm    
it is not provide accuracy if any other method is there or any code link so please tell me.
Dave Kreskowiak 21-Aug-23 16:50pm    
The speech engine in Windows is generic and needs to be trained over time. It gets better with usage, but only for the person that normally uses the machine. It will not have the same accuracy for other people.

3rd party engines, like Dragon Naturally Speaking are much better at it, but I don't know anything about it API.
[no name] 24-Aug-23 14:42pm    
It's a "2 part" problem. First you get it to recognize your speech and someone else's (if that's the plan). THEN, you can start thinking about translating.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900