שתף באמצעות


Speech to text in vb.net

Question

Sunday, October 2, 2016 9:57 PM

How do I make a program that you can talk into a mic and have what u said show in a textbox? I've looked everywhere on the internet and can't find a way how too.  (Needs to be in vb.net)

All replies (10)

Tuesday, October 4, 2016 1:51 AM ✅Answered

My goal is to make an application that helps you spell any word you say into your mic, is that possible?

I would say you have alot of research and learning to perform that. Specifically to learn how speech to text works and all the abilities you may need to learn to use with it prior to trying to write that program.

I didn't try the speech to text code as Reed mentions to use the default DictationGrammar which may work significantly better for single words.

And if the persons speech is not articulate then speech to text can not figure out what word they may be trying to say. Different people pronounce the same words differently depending on the area of a country they are from due to accent or improper teaching/learning of verbal skills for specific words in the U.S. anyhow. And people that are learning how to speak will have issues as will people trying to learn how to pronounce words.

It could be possible to host a WPF TextBox or RichTextBox in a Windows.Forms app as they have spell check based off some default dictionary and possibly could be used to help if speech to text displays some wacked out word but I'm not sure about that.

La vida loca


Sunday, October 2, 2016 10:12 PM

If you are looking for a free sample try:

http://www.codeproject.com/Articles/380027/Csharp-Speech-to-Text

It is in C# but there are online converters.

Also check out :

https://msdn.microsoft.com/en-us/magazine/dn857362.aspx?f=255&MSPPError=-2147217396

Lloyd Sheen


Monday, October 3, 2016 12:53 AM

Add a reference to System.Speech and then use code something like:

Imports System.Speech.Recognition

Public Class Form2
    Private WithEvents listener As New SpeechRecognizer

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        listener.LoadGrammar(New DictationGrammar)
    End Sub

    Private Sub listener_SpeechRecognized(sender As Object, e As SpeechRecognizedEventArgs) Handles listener.SpeechRecognized
        TextBox1.Text = e.Result.Text
    End Sub
End Class

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


Monday, October 3, 2016 2:45 AM

How do I make a program that you can talk into a mic and have what u said show in a textbox? I've looked everywhere on the internet and can't find a way how too.  (Needs to be in vb.net)

Speech to Text requires very specific information loaded into it so that it can understand phrases spoken into it. For example the below code loads a file of 69902 words, one word per line in the text file, and a single phrase on the last line of "I am doing well". So when I say "I am doing well" it seems to find that fine. However any other sentence I say gets broken up into single words which it has difficulty identifying any spoken word from similar words.

Also speech to text is a science as well as an art really. And there is alot of information on it at MSDN however there is a learning curve to understand how to use the capability.

You will probably need to read and understand how to use Create Grammars Using SRGS XML (Microsoft.Speech) and Semantic Interpretation Markup (Microsoft.Speech) among various other documents regarding Speech Recognition to eventually be able to provide appropriate information to a speech recognition engine for it to understand sentences, phrases, single words, how to insert commas, periods, question marks, quotation marks, etc for it to work well for actually performing speech to text. And that could take quite some time considering how many words are in the common dictionary even though many are never really used by most people.

Also see System.Speech.Recognition Namespace and SpeechRecognitionEngine Class.

Option Strict On

Imports System.Speech ' Add reference, Assemblies, Framework, System.Speech
Imports System.Speech.Recognition

Public Class Form1

    WithEvents RSR As New SpeechRecognitionEngine
    Dim Counter As Integer = 0

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
        TextBox1.WordWrap = True
        TextBox1.ScrollBars = ScrollBars.Vertical
        AddHandler RSR.SpeechRecognized, AddressOf RSR_SpeechRecognized
        Dim GrammarList As New List(Of String)
        Using SR As New IO.StreamReader(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "TestWordList", "WordList.Txt"))
            Do Until SR.EndOfStream
                GrammarList.Add(SR.ReadLine)
                Counter += 1
            Loop
        End Using
        Me.Text = "Form1 " & Counter.ToString
        Dim ChoicesToUse As New Choices(GrammarList.ToArray())
        GrammarList.Clear()
        Dim GB As New GrammarBuilder(ChoicesToUse)
        Dim GrammarToUse As New Grammar(GB)
        RSR.LoadGrammarAsync(GrammarToUse)
        RSR.SetInputToDefaultAudioDevice()
        RSR.RecognizeAsync(System.Speech.Recognition.RecognizeMode.Multiple)
    End Sub


    Private Sub RSR_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs)
        TextBox1.AppendText(e.Result.Text & " | " & e.Result.Confidence.ToString & vbCrLf)
    End Sub

End Class

La vida loca


Monday, October 3, 2016 11:19 AM

Speech to Text requires very specific information loaded into it so that it can understand phrases spoken into it.

La vida loca

Just load the dictation grammar for standard recognition:

listener.LoadGrammar(New DictationGrammar)

Custom grammars are only necessary in cases where you want to recognize only limited keywords or special terms.

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


Tuesday, October 4, 2016 1:28 AM

My goal is to make an application that helps you spell any word you say into your mic, is that possible?


Tuesday, October 4, 2016 3:23 PM

My goal is to make an application that helps you spell any word you say into your mic, is that possible?

Yes, the standard dictation grammar would do this - at least for the majority of common English words.  You'll have to speak carefully as MrMonkeyBoy has pointed out.  Individual users may need to train the speech recognition engine for better results.

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


Wednesday, October 12, 2016 1:58 AM

Take App Inventor 2 for example.  That has a component that lets you hit a button, a thing (by google) comes up that you talk into, then it comes out on to a textbox.  I know that's google and it's on an android but is there some way that can be made on a vb.net project? 


Wednesday, October 12, 2016 2:15 AM

Take App Inventor 2 for example.  That has a component that lets you hit a button, a thing (by google) comes up that you talk into, then it comes out on to a textbox.  I know that's google and it's on an android but is there some way that can be made on a vb.net project? 

Sure. You'll probably need anywhere from 6 months to a couple years to learn all you would need to know to program to the level necessary for App Inventor 2. It will probably take that long to learn both programming to the level necessary and researching how App Inventor 2 works in order to then be able to write a complex application that App Inventor 2 may be.

On the other hand App Inventor 2 seems to have been written by MIT. I suspect there's no lack of programmers at MIT and who knows how may people from MIT developed App Inventor 2 or what ranges of all their IQ levels and knowledge are that helped develop App Inventor 2. MIT seems to have a number 1 ranking for the smartest students of any college or university and I suspect most all of them have an IQ greater than 135 or so.

So maybe it will take longer than 6 months to a couple years to learn how to imitate App Inventor 2 in a VB.Net program for you.

On the other hand you should contact MIT to get advice on that really.

La vida loca


Wednesday, October 12, 2016 11:55 AM

Take App Inventor 2 for example.  That has a component that lets you hit a button, a thing (by google) comes up that you talk into, then it comes out on to a textbox.  I know that's google and it's on an android but is there some way that can be made on a vb.net project? 

That is essentially what the ten lines of code I previously posted would do. When ran, the Windows Speech applet would open, you would press the Listen button, talk into the mic, and the text would appear in the textbox.

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"