0

Can you help me? This code below have a stranger warning/error when launching. I get a message like "no recognizer is installed". What should I do? I'm already running it as x86 CPU.

Option Strict On

Imports System.Speech
Imports System.Speech.Recognition
Imports System.Speech.Recognition.SrgsGrammar

Public Class Form1

Dim WithEvents reco As New SpeechRecognitionEngine
Dim synth As New Synthesis.SpeechSynthesizer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Try

        Dim gram As New SrgsDocument
        Dim colorRule As New SrgsRule("color")
        Dim colorsList As New SrgsOneOf("red", "green")

        colorRule.Add(colorsList)
        gram.Rules.Add(colorRule)
        gram.Root = colorRule
        reco.LoadGrammarAsync(New Recognition.Grammar(gram))
        reco.SetInputToDefaultAudioDevice()
        reco.RecognizeAsync(RecognizeMode.Multiple)

    Catch s As Exception
        MessageBox.Show(s.Message)
    End Try


End Sub

Private Sub reco_SpeechDetected(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechDetectedEventArgs) Handles reco.SpeechDetected
    Label1.Text = "Voz detectada"
End Sub

Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized
    Select Case e.Result.Text
        Case "vermelho"
            SetColor(Color.Red)
        Case "verde"
            SetColor(Color.Lime)
    End Select
End Sub


Private Sub SetColor(ByVal color As System.Drawing.Color)
    reco.RecognizeAsyncCancel()
    reco.RecognizeAsyncStop()
    synth.Speak("mudando cor para " & color.ToString)
    Me.BackColor = color
    reco.RecognizeAsync(RecognizeMode.Multiple)
End Sub
End Class

P.S.: I'm running my Windows 7 in Portuguese, there's any problem?

spycode
  • 23
  • 8
  • Possible duplicate of [SpeechRecognitionEngine.InstalledRecognizers returns No recognizer installed](https://stackoverflow.com/questions/16856798/speechrecognitionengine-installedrecognizers-returns-no-recognizer-installed) – Clint Jan 29 '18 at 00:18
  • I saw this thread, but unfortunately the solution did not work for me – spycode Jan 29 '18 at 00:20
  • In Windows 7, you have to install [Microsoft Speech Platform](https://msdn.microsoft.com/en-us/library/office/hh361572(v=office.14).aspx). Install the SDK (for development), the Runtime (for distribution) and all relevant voices (Portuguese is included - Portugal and Brazil). Your assembly will be `Microsoft.Speech` (not `System.Speech`). The SDK includes a Grammar Builder/Validator. – Jimi Jan 30 '18 at 08:53

0 Answers0