private List <Frame> SplitIntoFrames(double[] speechSignal, int frameWidth, int frameShift) { int frameCount = GetFramesCount(speechSignal.Length, frameWidth, frameShift); var frames = new List <Frame>(); for (int i = 0; i < frameCount; i++) { int frameStart = i * frameShift; int frameEnd = GetFrameEnd(i, frameWidth, frameShift, speechSignal.Length); var frameBounds = new SpeechBounds(frameStart, frameEnd); double[] frameSingal = new double[frameBounds.Width]; Array.Copy(speechSignal, frameStart, frameSingal, 0, frameSingal.Length); var frame = new Frame(frameSingal, frameBounds); frames.Add(frame); } return(frames); }
public SignalContainer GetSpeech(SignalContainer rawSignal) { SignalContainer singal = rawSignal.Copy(); singal.FrameSize = 100; //ToDo! Constant change singal.FrameShift = singal.FrameSize; List <double> framesEnergy = singal.GetFrames().Select(frame => SignalHelper.GetAverageEnergy(frame.Signal)).ToList(); double averageEnergy = framesEnergy.Average(); double[] flattenedFramesEnergy = ApplyMeanFilter(framesEnergy.ToArray(), 3); SpeechBounds speechFramesBounds = GetSpeechBounds(flattenedFramesEnergy, averageEnergy); var speechFrames = singal.GetFrames().Skip(speechFramesBounds.Start).Take(speechFramesBounds.Width); double[] speechSignal = speechFrames.SelectMany(frame => frame.Signal).ToArray(); return(new SignalContainer(speechSignal) { FrameSize = rawSignal.FrameSize, FrameShift = rawSignal.FrameShift }); }
public FrameFeatures(SpeechBounds frameBounds, double[] features) { FrameBounds = frameBounds; vFeatures = new double[features.Length]; features.CopyTo(vFeatures, 0); }
public Frame(double[] signal, SpeechBounds bounds) { Signal = new double[signal.Length]; signal.CopyTo(Signal, 0); Bounds = bounds; }