微软语音服务器11 - 有没有人从波形文件中听写工作? [英] Microsoft Speech Server 11 - did anyone ever get dictation from a wave file to work?

查看:78
本文介绍了微软语音服务器11 - 有没有人从波形文件中听写工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用文档中的软件样本时,它无法识别任何内容 - 它只是输出空白...

When using the software samples from the documentation, it doesn't recognize anything - it just outputs blanks...

有没有人得到它来处理波形文件中的简单听写?

Did anyone ever get it to Work with simple dictation from a wave file?

推荐答案

嗨Klaus Jakobsen,

Hi Klaus Jakobsen,

感谢您发布此处。

对于您的问题,您要转换.wav文件的ID,您可以尝试下面的代码。

For your question, id you want to convert .wav file for text, you could try the code below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Speech.Recognition;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp
{
    class Convert_wav_to_text
    {
        static bool completed;

        static void Main(string[] args)

        // Initialize an in-process speech recognition engine.  
        {
            using (SpeechRecognitionEngine recognizer =
               new SpeechRecognitionEngine())
            {

                // Create and load a grammar.  
                Grammar dictation = new DictationGrammar
                {
                    Name = "Dictation Grammar"
                };

                recognizer.LoadGrammar(dictation);

                // Configure the input to the recognizer.  
                recognizer.SetInputToWaveFile(@"One.wav");

                // Attach event handlers for the results of recognition.  
                recognizer.SpeechRecognized +=
                  new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
                recognizer.RecognizeCompleted +=
                  new EventHandler<RecognizeCompletedEventArgs>(recognizer_RecognizeCompleted);

                // Perform recognition on the entire file.  
                Console.WriteLine("Starting asynchronous recognition...");
                completed = false;
                recognizer.RecognizeAsync();

                // Keep the console window open.  
                while (!completed)
                {
                    Console.ReadLine();
                }
                Console.WriteLine("Done.");
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }

        // Handle the SpeechRecognized event.  
        static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (e.Result != null && e.Result.Text != null)
            {
                Console.WriteLine("  Recognized text =  {0}", e.Result.Text);
            }
            else
            {
                Console.WriteLine("  Recognized text not available.");
            }
        }

        // Handle the RecognizeCompleted event.  
        static void recognizer_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Console.WriteLine("  Error encountered, {0}: {1}",
                e.Error.GetType().Name, e.Error.Message);
            }
            if (e.Cancelled)
            {
                Console.WriteLine("  Operation cancelled.");
            }
            if (e.InputStreamEnded)
            {
                Console.WriteLine("  End of stream encountered.");
            }
            completed = true;
        }
    }
}

请注意,c onversion不是很准确。

最诚挚的问候,

Wendy


这篇关于微软语音服务器11 - 有没有人从波形文件中听写工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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