Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 1D多峰检测?_Actionscript 3_Math_Matlab_Graph_Speech Recognition - Fatal编程技术网

Actionscript 3 1D多峰检测?

Actionscript 3 1D多峰检测?,actionscript-3,math,matlab,graph,speech-recognition,Actionscript 3,Math,Matlab,Graph,Speech Recognition,我目前正在尝试在AS3中实现基本的语音识别。我需要这是完全客户端,因为我无法访问强大的服务器端语音识别工具。我的想法是检测一个单词中的音节,并用它来确定所说的单词。我知道这将极大地限制识别能力,但我只需要识别几个关键词,我可以确保它们都有不同数量的音节 目前,我能够为一个口语单词生成一个1D声级数组,如果我以某种方式绘制它,我可以清楚地看到,在大多数情况下,音节都有明显的峰值。然而,我完全被困在如何找到这些峰值的问题上。我真的只需要伯爵,但我想那是找到他们的时候了。起初,我想获取一些最大值,并将

我目前正在尝试在AS3中实现基本的语音识别。我需要这是完全客户端,因为我无法访问强大的服务器端语音识别工具。我的想法是检测一个单词中的音节,并用它来确定所说的单词。我知道这将极大地限制识别能力,但我只需要识别几个关键词,我可以确保它们都有不同数量的音节

目前,我能够为一个口语单词生成一个1D声级数组,如果我以某种方式绘制它,我可以清楚地看到,在大多数情况下,音节都有明显的峰值。然而,我完全被困在如何找到这些峰值的问题上。我真的只需要伯爵,但我想那是找到他们的时候了。起初,我想获取一些最大值,并将它们与平均值进行比较,但我忘记了比其他峰值更大的峰值,因此,我所有的“峰值”都位于一个实际峰值上


我无意中发现它看起来太短了,几乎不可能是真的,但我不能确定这一点,因为我无法将它转换成我所知道的任何语言。我试过AS3和C。所以我想知道你们是否能让我走上正确的道路,或者有任何峰值检测的伪代码?

matlab代码非常简单。我会试着把它翻译成更伪代码的东西

它应该很容易翻译成ActionScript/C#,你应该试试这个,如果你陷入困境,你应该用你的代码发布后续问题,这样你会有最好的学习效果

Param: delta (defines kind of a tolerance and depends on your data, try out different values)
min = Inf (or some very high value)
max = -Inf (or some very low value)
lookformax = 1
for every datapoint d [0..maxdata] in array arr do
  this =  arr[d]
  if this > max
    max = this
    maxpos = d
  endif
  if this < min
    min = this
    minpos = d
  endif

  if lookformax == 1
    if this < max-delta
      there's a maximum at position maxpos
      min = this
      minpos = d
      lookformax = 0
    endif
  else
    if this > min+delta
      there's a minimum at position minpos
      max = this
      maxpos = d
      lookformax = 1
    endif
  endif
Param:delta(定义一种公差,取决于您的数据,请尝试不同的值)
min=Inf(或某些非常高的值)
max=-Inf(或一些非常低的值)
lookformax=1
对于阵列arr do中的每个数据点d[0..maxdata]
这=arr[d]
如果这个>最大值
max=这个
maxpos=d
恩迪夫
如果这最小+增量
在minpos位置有一个最小值
max=这个
maxpos=d
lookformax=1
恩迪夫
恩迪夫

查找曲线的峰值和谷值就是查看直线的坡度。在该位置,坡度为0。因为我猜声音曲线是非常不规则的,所以必须首先对其进行平滑处理,直到只存在显著的峰值


在我看来,曲线应该是一组点。应平均点组,以生成简单的平滑曲线。然后比较每个点的差异,找出彼此差异不大的点,并将这些区域确定为峰、谷或高原

如果有人想要AS3中的最终代码,请参见:

function detectPeaks(values:Array, tolerance:int):void
{


var min:int = int.MIN_VALUE;
var max:int = int.MAX_VALUE;
var lookformax:int = 1;
var maxpos:int = 0;
var minpos:int = 0;

for(var i:int = 0; i < values.length; i++)
{
    var v:int = values[i];
    if (v > max)
    {
        max = v;
        maxpos = i;
    }
    if (v < min)
    {
        min = v;
        minpos = i;
    }

    if (lookformax == 1)
    {
        if (v < max - tolerance)
        {
            canvas.graphics.beginFill(0x00FF00);
            canvas.graphics.drawCircle(maxpos % stage.stageWidth, (1 - (values[maxpos] / 100)) * stage.stageHeight, 5);
            canvas.graphics.endFill();

            min = v;
            minpos = i;
            lookformax = 0;
        }
    }
    else
    {
        if (v > min + tolerance)
        {
            canvas.graphics.beginFill(0xFF0000);
            canvas.graphics.drawCircle(minpos % stage.stageWidth, (1 - (values[minpos] / 100)) * stage.stageHeight, 5);
            canvas.graphics.endFill();

            max = v;
            maxpos = i;
            lookformax = 1;
        }
    }
}
函数检测峰值(值:数组,公差:int):无效
{
var min:int=int.min\u值;
var max:int=int.max\u值;
var lookformax:int=1;
var maxpos:int=0;
var minpos:int=0;
对于(变量i:int=0;i最大值)
{
最大值=v;
maxpos=i;
}
如果(v最小值+公差)
{
canvas.graphics.beginll(0xFF0000);
canvas.graphics.drawCircle(minpos%stage.stageWidth,(1-(值[minpos]/100))*stage.stageHeight,5);
canvas.graphics.endFill();
最大值=v;
maxpos=i;
lookformax=1;
}
}
}

}

此函数不返回任何内容,但如果返回,它是否只返回最高峰值的索引,而不是所有峰值?