本文介绍了语音识别编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设计以下项目,该项目将语音转换为文本"

但显示以下运行时异常:

未处理PlatformNotSupportedException
语音识别在此系统上不可用.找不到SAPI和语音识别引擎.

请给我建议一些解决方案.

代码如下:

I am trying to design following project which converts "Speech to text"

but it shows following runtime exception:

PlatformNotSupportedException was Unhandled
Speech Recognition is not available on this system. SAPI and Speech Recognition engines cannot be found.

Please suggest me some solution for it.

Code is as under:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Speech.Recognition;

namespace speech_Recognition
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>


    public partial class Window1 : Window
    {
        private SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine();

        public Window1()
        {
            InitializeComponent();
        }

        private void button_Rec_Click(object sender, RoutedEventArgs e)
        {
            _recognizer.SetInputToDefaultAudioDevice();
            _recognizer.LoadGrammar(new DictationGrammar());
            _recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_recognizer_SpeechRecognized);
            _recognizer.RecognizeAsync(RecognizeMode.Multiple);
        }

        void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            foreach (RecognizedWordUnit word in e.Result.Words)
            {
                listBox_Results.Items.Add(word.Text);
            }
        }
    }
}



[已编辑]未选中忽略HTML标签和实体[/已编辑]



Unchecked Ignore HTML tags and entities[/Edited]

推荐答案


这篇关于语音识别编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 15:09