private void vadVoice(string path)
        {
            WavFileWrapper wav = new WavFileWrapper(path);

            if (wav.Load())
            {
                VadWrapper vad = new VadWrapper(wav);
                vad.UseEnergy(0.015f, 0.01f, true, 3, false);
                if (vad.Process(option.EnergyThreshold))
                {
                    float begin = 0;
                    float end   = 0;
                    uint  deta  = 0;
                    for (uint i = 0; i < vad.GetSizeOfSegment(); i++)
                    {
                        if (vad.GetEndSegment(i) - vad.GetStartSegment(i) > deta)
                        {
                            deta  = vad.GetEndSegment(i) - vad.GetStartSegment(i);
                            begin = (float)vad.GetStartSegment(i);
                            end   = (float)vad.GetEndSegment(i);
                        }
                    }
                    if (deta > 0)
                    {
                        int size = wav.FullData.Count;
                        _startSelected            = begin / size;
                        _endSelected              = end / size;
                        waveViewer.LeftSlider     = _startSelected;
                        waveViewer.RightSlider    = _endSelected;
                        waveViewer.ThresholdChart = (float)vad.ThresholdEnergy;
                        waveViewer.Chart          = vad.SmoothEnergies;
                    }
                }
            }
        }
Пример #2
0
 private void vadVoice()
 {
     option = VCContext.Instance.MFCCOptions;
     if (_yourWav != null && _yourWav.IsValid)
     {
         VadWrapper      vad = new VadWrapper(_yourWav);
         ZeroRateWrapper zrc = new ZeroRateWrapper(_yourWav, 0.02f, 0.01f, true);
         vad.UseEnergy(0.015f, 0.01f, true, 3, false);
         zrc.Process();
         if (vad.Process(option.EnergyThreshold))
         {
             float begin = 0;
             float end   = 0;
             uint  deta  = 0;
             for (uint i = 0; i < vad.GetSizeOfSegment(); i++)
             {
                 if (vad.GetEndSegment(i) - vad.GetStartSegment(i) > deta)
                 {
                     deta  = vad.GetEndSegment(i) - vad.GetStartSegment(i);
                     begin = (float)vad.GetStartSegment(i);
                     end   = (float)vad.GetEndSegment(i);
                 }
             }
             if (deta > 0)
             {
                 int size = _yourWav.FullData.Count;
                 _startSelected            = begin / size;
                 _endSelected              = end / size;
                 waveViewer.LeftSlider     = _startSelected;
                 waveViewer.RightSlider    = _endSelected;
                 waveViewer.ThresholdChart = (float)vad.ThresholdEnergy;
                 //waveViewer.Chart = vad.SmoothEnergies;
                 waveViewer.ChartBlue = zrc.ZeroRate;
             }
         }
     }
 }