• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

vb.net microsoft voice platform help

Joined
Dec 22, 2007
Messages
184 (0.03/day)
Location
Central Nebraska
System Name CORSAIR
Processor AMD Phenom 1090T x6 @3.2
Motherboard Gigabyte Ga-78LMT-S2P
Cooling High efficiency dust cooling
Memory 8GB GSkill DDR3 1333
Video Card(s) Sapphire Radeon HD3870 512MB GDDR4 PCI-e toxic
Storage Seagate SV35.3 ST3250310SV 250GB SATAII(Windows 7 Pro x64), 320GB Samsung SATAII(Storage and SuSE)
Display(s) Dell 20" LCD, Dell 17" LCD
Power Supply Antec Cool Blue 650W Modular
Software Windows 7 Professional SP1, Visual Studio 2010 Ultimate
writing an auto dication application using the microsoft voice platform 11 (Speech SDK): have a few questions on it. the application has a start and stop button which should start and stop the voice engine from listening.

Question 1: when I click the start button, the microsoft speech recognition UI pops up alongside the application - is there a way to keep this from happening and completely control the speech functionality through MY application?

Question 2: the start and stop buttons do not start and stop anything despite these line of code:
Code:
Grammar.DictationSetState(SpeechRuleState.SGDSActive)
and:
Code:
Grammar.DictationSetState(SpeechRuleState.SGDSInactive)

You still have to use the speech engine UI to start and stop listening, any idea on how to actually call it to start listenning through a vb.net button?

Full code is here:
Code:
Imports System
Imports System.Data
Imports System.Deployment
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Xml
Imports System.Speech
Imports SpeechLib

Public Class Form1
    Dim WithEvents RecoContext As SpSharedRecoContext
    Dim Grammar As ISpeechRecoGrammar
    Dim CharCount As Integer
    Dim var_TextInsetion As Boolean = True
    Dim var_ReadBack As Boolean = False

    Private Sub Button_Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Start.Click
        If (RecoContext Is Nothing) Then
            RecoContext = New SpSharedRecoContext
            Grammar = RecoContext.CreateGrammar(1)
            Grammar.DictationLoad()
        End If
        Grammar.DictationSetState(SpeechRuleState.SGDSActive)
        Button_Start.Enabled = False
        Button_Stop.Enabled = True

    End Sub

    Private Sub Button_Stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Stop.Click

        Grammar.DictationSetState(SpeechRuleState.SGDSInactive) 'Turns off the Recognition. It will go dormant.

        Button_Start.Enabled = True
        Button_Stop.Enabled = False
    End Sub

    Private Sub OnHypo(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal Result As ISpeechRecoResult) Handles RecoContext.Hypothesis
        Button_Stop.Enabled = False
        Label_Phrase.Text = "Dictating..."
    End Sub



    Private Sub OnReco(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechRecognitionType, ByVal Result As ISpeechRecoResult) Handles RecoContext.Recognition
        'create text string from recognized speech
        Dim recoResult As String = Result.PhraseInfo.GetText
        Label_Phrase.Text = recoResult & " "
        CharCount = CharCount + 1 + Len(recoResult)
        If var_TextInsetion = True Then
            SendKeys.Send(recoResult & " ")
        End If
        Button_Stop.Enabled = True
        If var_ReadBack = True Then
            If recoResult = "Backspace" Or recoResult.StartsWith("Select") Then
            Else
                Dim synth
                synth = CreateObject("SAPI.spvoice")
                synth.Speak(recoResult)
            End If
        End If
    End Sub


    Private Sub CheckBox_TextInsertion_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox_TextInsertion.CheckedChanged
        If CheckBox_TextInsertion.CheckState = CheckState.Checked Then
            var_TextInsetion = True
        Else
            var_TextInsetion = False
        End If
    End Sub

    Private Sub CheckBox_ReadBack_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox_ReadBack.CheckedChanged
        If CheckBox_ReadBack.CheckState = CheckState.Checked Then
            var_ReadBack = True
        Else
            var_ReadBack = False
        End If
    End Sub
End Class
 
Last edited:
Any ideas? Or does anyone know anywhere I could ask that is familiar with this SDK?
 
I've not used the Speech SDK. I would be interested to see some screen shots of the Speech engine UI popup. So, if I understand what you are saying.. You created a button that calls the Speech engine UI popup event? You should be able to do something like take the start button on the speech engine UI and (I don't know what it's called this is just an example) bt_start.performclick inside your button click event.
 
Last edited:
Back
Top