“SAPI没有实现拼音字母选择'例外拼音字母、SAPI

2023-09-04 01:05:18 作者:颜王

每当我试图code任何语音识别程序在我的笔记本电脑,我总是得到相同的消息中提到below..I可以随时编译我的code,并得到Windows窗体应用程序working..But的问题是,该程序将无法检测到我的voice..And程序无法正常工作。

我很相信我的codeS工作正常,我通常采取codeS来自YouTube的视频,如:的 https://www.youtube.com/watch?v=KR0-UYUGYgA ,还有更多.. 我使用.NET Framework 4的客户端配置文件为我的项目。我做参考,以system.speech......可能是我的问题?

调试消息,我得到的:

  speaker.vshost.exe信息:0:SAPI没有实现拼音字母的选择。
第一个机会异常类型'System.Runtime.InteropServices.COMException'在System.Speech.dll发生
第一个机会异常类型的'System.InvalidOperationException'在System.Speech.dll发生
第一个机会异常类型的'System.InvalidOperationException'在System.Speech.dll发生
第一个机会异常类型的'System.InvalidOperationException'在System.Speech.dll发生
 

样品code,我试过:

 使用系统;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data这;
使用System.Drawing中;
使用System.Linq的;
使用System.Text;
使用System.Windows.Forms的;
使用System.Speech.Synthesis;
使用System.Speech.Recognition;
使用的System.Threading;
使用System.Threading.Tasks;

命名空间扬声器
{
    公共部分类Form1中:形态
    {
        公共Form1中()
        {
            的InitializeComponent();
        }

        SpeechSynthesizer sSynth =新SpeechSynthesizer();
        PromptBuilder pBuilder =新PromptBuilder();
        SpeechRecognitionEngine sRecognize =新SpeechRecognitionEngine();

        私人无效Form1_Load的(对象发件人,EventArgs的)
        {

        }

        私人无效的button1_Click(对象发件人,EventArgs的)
        {
            pBuilder.ClearContent();
            pBuilder.AppendText(textBox1.Text);
            sSynth.Speak(pBuilder);
        }

        私人无效button2_Click(对象发件人,EventArgs的)
        {
            button2.Enabled = FALSE;
            button2.Enabled = TRUE;
            选择SLIST =新的选择();
            sList.Add(新的String [] {你好,测试,它的工作原理,怎么做,是,你,今天});
            语法克=新的语法(新GrammarBuilder(SLIST));

            尝试
            {
                sRecognize.RequestRecognizerUpdate();
                sRecognize.LoadGrammar(克);
                sRecognize.SpeechRecognized + =新的EventHandler< SpeechRecognizedEventArgs>(sRecognize_SpeechRecognized);
                sRecognize.SetInputToDefaultAudioDevice();
                sRecognize.RecognizeAsync(RecognizeMode.Multiple);
            }
            抓住
            {
                返回;
            }
        }

        无效sRecognize_SpeechRecognized(对象发件人,SpeechRecognizedEventArgs E)
        {
            //如果(e.Result.Confidence> = 0.3)
            的MessageBox.show(讲话:+ e.Result.Text.ToString());
        }


    }
}
 

解决方案 QQ拼音 字母选字

您需要

  gram.Culture =新System.Globalization.CultureInfo(EN-GB)
 

有关详细信息请参见

http://www.vbforums.com/showthread.php?751297-RESOLVED-(VS2102)-Speech-Recognition-Suddenly-Stopped

您可以轻松解决这类问题与谷歌头也不回的左右。

Whenever I attempt to code any speech recognition program in my laptop,I always get the same messages as mentioned below..I can always compile my code and get the windows form application working..But the problem is, the program will not detect my voice..And the program wont work..

I am very sure my codes works fine as I usually take the codes from youtube videos like : https://www.youtube.com/watch?v=KR0-UYUGYgA and many more.. I am using .NET framework 4 client profile for my projects.. I make reference only to "system.speech"...What might be my problem ?

Debug messages that I get :

speaker.vshost.exe Information: 0 : SAPI does not implement phonetic alphabet selection.
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Speech.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Speech.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Speech.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Speech.dll

Sample code that I tried :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Synthesis;
using System.Speech.Recognition;
using System.Threading;
using System.Threading.Tasks;

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

        SpeechSynthesizer sSynth = new SpeechSynthesizer();
        PromptBuilder pBuilder = new PromptBuilder();
        SpeechRecognitionEngine sRecognize = new SpeechRecognitionEngine();

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            pBuilder.ClearContent();
            pBuilder.AppendText(textBox1.Text);
            sSynth.Speak(pBuilder);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            button2.Enabled = false;
            button2.Enabled = true;
            Choices sList = new Choices();
            sList.Add(new string[]{"hello","test","it works","how","are","you","today"});
            Grammar gr = new Grammar(new GrammarBuilder(sList));

            try
            {
                sRecognize.RequestRecognizerUpdate();
                sRecognize.LoadGrammar(gr);
                sRecognize.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sRecognize_SpeechRecognized);
                sRecognize.SetInputToDefaultAudioDevice();
                sRecognize.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch
            {
                return;
            }
        }

        void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //if (e.Result.Confidence >= 0.3)
            MessageBox.Show("speech is:" + e.Result.Text.ToString());
        }


    }
}

解决方案

You need

 gram.Culture = New System.Globalization.CultureInfo("en-GB")

For more details see

http://www.vbforums.com/showthread.php?751297-RESOLVED-(VS2102)-Speech-Recognition-Suddenly-Stopped

You can easily solve problems like this with google without looking on SO.