本文介绍了音频识别问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个认可项目。它可以工作,但如果我使用这个项目如何一个类,并从其他类调用其方法我有一个问题与线上的异常 sre = new SpeechRecognitionEngine ( ri 。 Id ); : 无识别者找到所需的ID。 KinectAudioSource source = kinectSensor.AudioSource; source.EchoCancellationMode = EchoCancellationMode.None; //此示例源没有AEC .AutomaticGainControlEnabled = false; //重要的是关闭它以进行语音识别// source.SystemMode = SystemMode.OptibeamArrayOnly; speechRecognizer = CreateSpeechRecognizer(); using(Stream s = source.Start()){speechRecognizer.SetInputToAudioStream(s,new SpeechAudioFormatInfo(EncodingFormat.Pcm,16000,16,1,32000,2,null)); Console.WriteLine("识别语音。说:'紫色','绿色'或'蓝色'。按ENTER键停止'); speechRecognizer.RecognizeAsync(RecognizeMode.Multiple);到Console.ReadLine(); Console.WriteLine("Stopping Recognizer ..."); speechRecognizer.RecognizeAsyncStop(); } private static SpeechRecognitionEngine CreateSpeechRecognizer(){RecognizerInfo ri = GetKinectRecognizer(); SpeechRecognitionEngine sre; // if(ri == null)返回0; sre = new SpeechRecognitionEngine(ri.Id); var colors = new Choices(); colors.Add(QUOT;红色"); colors.Add(QUOT;绿色"); colors.Add(QUOT;蓝色"); var gb = new GrammarBuilder {Culture = ri.Culture}; gb.Append(颜色); //创建实际的语法实例,然后将其加载到语音识别器中。 var g = new Grammar(gb); sre.LoadGrammar(克); sre.SpeechRecognized + = SreSpeechRecognized; sre.SpeechHypothesized + = SreSpeechHypothesized; sre.SpeechRecognitionRejected + = SreSpeechRecognitionRejected;返回sre; } private static RecognizerInfo GetKinectRecognizer(){Func< RecognizerInfo,bool> matchingFunc = r => { 字符串值; r.AdditionalInfo.TryGetValue(" Kinect",out value); return" True" .Equals(value,StringComparison.InvariantCultureIgnoreCase)&& "en-US".Equals(r.Culture.Name,StringComparison.InvariantCultureIgnoreCase); }; return SpeechRecognitionEngine.InstalledRecognizers()。Where(matchingFunc).FirstOrDefault(); } 解决方案 异常的类型是什么 你可以解释一下 I have a project for recognition. It works, but if i use this project how a class and call its methods from other class i have a problem with exception on line sre= newSpeechRecognitionEngine(ri.Id); :No recognizer of the required ID found. KinectAudioSource source = kinectSensor.AudioSource; source.EchoCancellationMode = EchoCancellationMode.None; // No AEC for this sample source.AutomaticGainControlEnabled = false; // Important to turn this off for speech recognition // source.SystemMode = SystemMode.OptibeamArrayOnly; speechRecognizer = CreateSpeechRecognizer(); using (Stream s = source.Start()) { speechRecognizer.SetInputToAudioStream( s, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null)); Console.WriteLine("Recognizing speech. Say: 'purple', 'green' or 'blue'. Press ENTER to stop"); speechRecognizer.RecognizeAsync(RecognizeMode.Multiple); Console.ReadLine(); Console.WriteLine("Stopping recognizer ..."); speechRecognizer.RecognizeAsyncStop(); } private static SpeechRecognitionEngine CreateSpeechRecognizer() { RecognizerInfo ri = GetKinectRecognizer(); SpeechRecognitionEngine sre; //if (ri == null) return 0; sre = new SpeechRecognitionEngine(ri.Id); var colors = new Choices(); colors.Add("red"); colors.Add("green"); colors.Add("blue"); var gb = new GrammarBuilder { Culture = ri.Culture }; gb.Append(colors); // Create the actual Grammar instance, and then load it into the speech recognizer. var g = new Grammar(gb); sre.LoadGrammar(g); sre.SpeechRecognized += SreSpeechRecognized; sre.SpeechHypothesized += SreSpeechHypothesized; sre.SpeechRecognitionRejected += SreSpeechRecognitionRejected; return sre; } private static RecognizerInfo GetKinectRecognizer() { Func<RecognizerInfo, bool> matchingFunc = r => { string value; r.AdditionalInfo.TryGetValue("Kinect", out value); return "True".Equals(value, StringComparison.InvariantCultureIgnoreCase) && "en-US".Equals(r.Culture.Name, StringComparison.InvariantCultureIgnoreCase); }; return SpeechRecognitionEngine.InstalledRecognizers().Where(matchingFunc).FirstOrDefault(); } 解决方案 what is the type of the exceptioncould you please explain 这篇关于音频识别问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 05-25 23:56