如何修复Visual Studio 2019中的'未安装识别器'

问题描述 投票:0回答:1

我创建了控制台应用程序(.Net Framework),将音频转换为文本并在控制台上显示文本,但是当我尝试运行该程序时会引发错误:

System.PlatformNotSupportedException:'未安装识别器。 '

我已经安装了(https://www.microsoft.com/en-us/download/details.aspx?id=14373“ Microsoft Speech Platform SDK”和(https://www.microsoft.com/en-us/download/details.aspx?id=27224“运行时语言”),但仍然不想运行。有什么建议吗?

我已经尝试过找出我有什么版本,但是什么都没有显示。

foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
{
         System.Diagnostics.Debug.WriteLine(ri.Culture.Name);
         Console.WriteLine(ri.Culture.Name);
}

Console.WriteLine("Done");
Console.ReadLine();

我在不同主题的stackoverflow上找到了具有相同问题的代码,但他有一些输出,我没有任何输出。

这是我正在使用的代码,但错误显示在engine.SetInputToDefaultAudioDevice()处,但我不知道如何解决它

using System;
using System.Speech.Recognition;
using System.Speech.Synthesis;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            SpeechRecognitionEngine engine = new SpeechRecognitionEngine();
            SpeechSynthesizer Sarah = new SpeechSynthesizer();            
            engine.SetInputToDefaultAudioDevice();

            while (true)
            {
                engine.LoadGrammarAsync(new Grammar(new GrammarBuilder(new Choices(new string[] { "Hello", "How are you" }))));
                engine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(Default_SpeechRecognized);
                engine.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(_recognizer_SpeechRecognized);
                engine.RecognizeAsync(RecognizeMode.Multiple);
            }

            Console.ReadLine();
        }

        private static void _recognizer_SpeechRecognized(object sender, SpeechDetectedEventArgs e)
        {
            string words = e.ToString();
            Console.WriteLine(words);
        }

        private static void Default_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string words = e.ToString();
            Console.WriteLine(words);
        }
    }
}
c# visual-studio speech-recognition voice-recognition visual-studio-2019
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.