标签:c# kinect visual studio 语音识别
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Kinect; namespace KinectListener { class Program { static KinectAudioSource AudioSourceSetup(KinectAudioSource source) { //对我们的KinectAudioSource对象进行初始化 source.NoiseSuppression = true;//开启抑制噪声功能 source.AutomaticGainControlEnabled = true;//自动增益控制功能 source.BeamAngleMode = BeamAngleMode.Adaptive;//设置BeamAngleMode为adaptive属性,适合环境噪声大的环境 return source; } static void SoundTracking(KinectAudioSource source) { source = AudioSourceSetup(source);//对传入的KinectAudioSource对象初始化 source.BeamAngleChanged += audioSource_BeamAngleChanged; source.SoundSourceAngleChanged += audioSource_SoundSourceAngleChanged; //初始化后,注册时间处理函数 source.Start();//启动KinectAudioSource对象 } static void audioSource_BeamAngleChanged(object sender, BeamAngleChangedEventArgs e) { //事件处理函数 取得麦克风阵列最新对准的方向 string output = "侦测到Beam Angle :"+ e.Angle.ToString(); Console.WriteLine(output); } static void audioSource_SoundSourceAngleChanged(object sender, SoundSourceAngleChangedEventArgs e) { //事件处理函数 取得当前声音来源方向 string output = "侦测到Source Angle:" + e.Angle.ToString() + ", Source Confidence :" + e.ConfidenceLevel.ToString(); Console.WriteLine(output); } static void Main(string[] args) { KinectSensor sensor = KinectSensor.KinectSensors[0];//获得传感器 sensor.Start();//启动传感器 KinectAudioSource source = sensor.AudioSource; //要使用Kinect的声音功能,必须从KinectSensor对象中取出AudioSensor对象 SoundTracking(source);//追踪声音 Console.WriteLine("退出请按空格键"); string maxmin1 = ",最大Beam Angle :" + KinectAudioSource.MaxBeamAngle + ",最小Beam Angle :" + KinectAudioSource.MinBeamAngle; string maxmin2 = ",最大Source Angle :" + KinectAudioSource.MaxSoundSourceAngle + ",最小Source Angle :" + KinectAudioSource.MinSoundSourceAngle; Console.WriteLine(maxmin1); Console.WriteLine(maxmin2); while (Console.ReadKey().Key != ConsoleKey.Spacebar) { } sensor.Stop(); } } }
source.BeamAngleChanged
+= audioSource_BeamAngleChanged;
source.SoundSourceAngleChanged
+= audioSource_SoundSourceAngleChanged;
标签:c# kinect visual studio 语音识别
原文地址:http://blog.csdn.net/u012200908/article/details/44903167