永发信息网

C# 语音识别后想把输出从中文变成英文

答案:2  悬赏:70  手机版
解决时间 2021-03-17 21:37
  • 提问者网友:相思似海深
  • 2021-03-17 14:38
using System;
using System.IO;
using System.Speech.Recognition;
using System.Speech.AudioFormat;

namespace SampleRecognition
{
class Program
{
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();
dictation.Name = "Dictation Grammar";

recognizer.LoadGrammar(dictation);

// Configure the input to the recognizer.
recognizer.SetInputToWaveFile(@"c:\temp\green.wav");

// Attach event handlers for the results of recognition.
recognizer.SpeechRecognized +=
new EventHandler(recognizer_SpeechRecognized);
recognizer.RecognizeCompleted +=
new EventHandler(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;
}
}
}

这是msdn里的范例源码, 我green.wva文件里的音频是green一个单词,识别出来之后输出是中文“图林”,我需要怎么把他改成英文并且正确识别呢?

我自己本身是中文的win7操作系统
最佳答案
  • 五星知识达人网友:渊鱼
  • 2021-03-17 16:16
涉及到语音识别,是研究生的课题,拿来百度知道问似乎不妥。
全部回答
  • 1楼网友:你哪知我潦倒为你
  • 2021-03-17 16:43
sapi.51 sdk能实现文字语言输出,你说的发音输出文字,应该也不是问题,看看它的msdn相关帮助吧
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯