使用sapi的错误识别 [英] Wrong recognition using sapi

查看:205
本文介绍了使用sapi的错误识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我开发了一个使用c#将wav文件转换为文本的应用程序.使用SAPI TTS应用程序工具,我将wav文件保存在Microsoft语音本身中.为了获得准确的识别,我只将其保存为Microsoft Voice.虽然结果不准确.它会错误地识别单词,例如需要见面和可爱而愚蠢等.
我附上了我的代码.

hi ,
I developed an application which converts wav file to text using c#. Using SAPI TTS app tool i saved the wav file in microsoft voice itself. For accurate recognition only i saved it in microsoft voice. Though the result is not accurate. It is recognizing the words wrongly, such as meeting as needing and cute as dubed etc.
I attached my code with it.

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.IO;
using SpeechLib;
namespace using_wav
{
    public partial class Form1 : Form
    {
        private SpeechLib.ISpeechRecoContext wavRecoContext = null;
        private SpeechLib.SpFileStream InputWAV = null;
        private SpeechLib.ISpeechRecoGrammar Grammar = null;
        private String _WAVFile = null;
        private string strData = "No recording yet";
        private String _lastRecognized = "";

        public Form1()
        {
            InitializeComponent();
        }
        private void button2_Click(object sender, EventArgs e)
        {
           Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
           //String[] filePaths = Directory.GetFiles(@"c:\MyDir\", "*.bmp",
           //                              SearchOption.AllDirectories);
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title =
            "Select a Speech file";
            dialog.ShowDialog();
            _WAVFile = dialog.FileName;
           //_WAVFile = dialog.filePaths;
            if (_WAVFile == null) return;
            wavRecoContext =new SpeechLib.SpInProcRecoContext();
            ((SpInProcRecoContext)wavRecoContext).Recognition +=new _ISpeechRecoContextEvents_RecognitionEventHandler(wavRecoContext_Recognition);
            ((SpInProcRecoContext)wavRecoContext).EndStream += new _ISpeechRecoContextEvents_EndStreamEventHandler(wavRecoContext_EndStream);
            Grammar = wavRecoContext.CreateGrammar(2);
            Grammar.DictationLoad("", SpeechLoadOption.SLOStatic);
            InputWAV = new SpFileStream();
            InputWAV.Open(@_WAVFile,SpeechStreamFileMode.SSFMOpenForRead, false);
            wavRecoContext.Recognizer.AudioInputStream = InputWAV;
            Grammar.DictationSetState(SpeechRuleState.SGDSActive);
            }
        private void wavRecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
        {
            strData = Result.PhraseInfo.GetText(0, -1,true);
            _lastRecognized = textBox1.Text;
            textBox1.Text = strData;
        }
        private void wavRecoContext_EndStream(int StreamNumber, object StreamPosition, bool f)
        {
            Grammar.DictationSetState(
            SpeechRuleState.SGDSInactive); 
        }
    }
}


该代码是否有任何错误.
提前谢谢.

[edit]添加了代码块-OriginalGriff [/edit]


Is there any fault in this code.
Thanks in advance.

[edit]Code block added - OriginalGriff[/edit]

推荐答案

是什么让您认为使用合成语音会使识别更加准确?我认为这是相反的,因为合成语音不能总是正确地说出每个单词.
What made you think that using a synthesized voice was going to make recognition more accurate?? I''d think it would be jsut the opposite as synthesized speech doesn''t always say every word properly.


首先,您不需要直接使用SAPI这个简单的任务.您可以在CAG中可用的程序集"System.Speech"中简单地使用名称空间System.Speech.Recognition.它与(自由分发的).NET Framework运行时程序包捆绑在一起,并且易于使用.

识别质量刚好低于您的预期.为了获得更好的结果,请仅使用带有明显不同表达的小语法.发音更清晰. :-)

—SA
First of all, you don''t need to use SAPI directly for this simple task. You could simply use the namespace System.Speech.Recognition in the assembly "System.Speech" available in CAG. It is bundled with (freely distributed) .NET Framework runtime package and is easy to use.

The recognition quality is just lower than what you expected. For better results, use only small grammars with clearly distinct expressions. Pronounce more clearly. :-)

—SA


这篇关于使用sapi的错误识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆