c# - 仅检测来自 Kinect 正前方用户的语音

标签 c# kinect

我想让 kinect 只接收直接在它前面的用户的语音。 我不希望检测到噪音或人们在右边或左边说话。 或者如果用户移动到 kinect 的右侧或左侧。 这可能吗?

var audioSource = this.Kinect.AudioSource;
audioSource.BeamAngleMode = BeamAngleMode.Adaptive;
var kinectStream = audioSource.Start();

我玩过 ManualBeamAngle,但我不认为那是我想要的。

如有任何帮助,我们将不胜感激。 cp

最佳答案

你可以用Source angle来找到这个,它们在中间的时候都是0。参见 Audio Basics - WPF ,并将代码更改为:

    double sourceAngle;

    ...

    private void AudioSourceBeamChanged(object sender, BeamAngleChangedEventArgs e)
    {
        beamRotation.Angle = -e.Angle;
        sourceAngle = e.Angle;
        beamAngleText.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.BeamAngle, e.Angle.ToString("0", CultureInfo.CurrentCulture));
    }

    private void AudioSourceBeamChanged(object sender, BeamAngleChangedEventArgs e)
    {
        beamRotation.Angle = -e.Angle;
        beamAngleText.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.BeamAngle, e.Angle.ToString("0", CultureInfo.CurrentCulture));
    }

    private void AudioReadingThread()
    {
        // Bottom portion of computed energy signal that will be discarded as noise.
        // Only portion of signal above noise floor will be displayed.
        const double EnergyNoiseFloor = 0.2;

        while (this.reading)
        {
            while (sourceAngle == 0) //this is the important part
            {
                int readCount = audioStream.Read(audioBuffer, 0, audioBuffer.Length);

                // Calculate energy corresponding to captured audio in the dispatcher
                // (UI Thread) context, so that rendering code doesn't need to
                // perform additional synchronization.
                Dispatcher.BeginInvoke(
                new Action(
                    () =>
                    {
                        for (int i = 0; i < readCount; i += 2)
                        {
                            // compute the sum of squares of audio samples that will get accumulated
                            // into a single energy value.
                            short audioSample = BitConverter.ToInt16(audioBuffer, i);
                            this.accumulatedSquareSum += audioSample * audioSample;
                            ++this.accumulatedSampleCount;

                            if (this.accumulatedSampleCount < SamplesPerColumn)
                            {
                                continue;
                            }

                            // Each energy value will represent the logarithm of the mean of the
                            // sum of squares of a group of audio samples.
                            double meanSquare = this.accumulatedSquareSum / SamplesPerColumn;
                            double amplitude = Math.Log(meanSquare) / Math.Log(int.MaxValue);

                            // Renormalize signal above noise floor to [0,1] range.
                            this.energy[this.energyIndex] = Math.Max(0, amplitude - EnergyNoiseFloor) / (1 - EnergyNoiseFloor);
                            this.energyIndex = (this.energyIndex + 1) % this.energy.Length;

                            this.accumulatedSquareSum = 0;
                            this.accumulatedSampleCount = 0;
                            ++this.newEnergyAvailable;
                        }
                    }));
            }
        }

sourceAngle == 0) 为我们做了这个。希望这对您有所帮助!

关于c# - 仅检测来自 Kinect 正前方用户的语音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12080457/

相关文章:

c# - 如何在当前项目中已存在的 T4 文本模板中引用类?

c# - 检查字符串中的字母数字和特殊字符

java - Java 应用程序与 C++ 应用程序之间的通信

c++ - std::async 返回值。未知错误

python - 如何在Python中使用openkinect捕获视差图像?

c# - 颜色空间点到深度空间点

c# - ServiceStack Client Put请求和查询参数

c# - EF Core 2.1.4 FileLoadException System.ComponentModel.Annotations 4.2.0.0

c# - 如何将 TreeView 中的 SelectedItemValue 绑定(bind)回 Silverlight 中的 ViewModel?

c# - 使用 Kinect SDK 进行联合跟踪