我想让 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/