private SignalContainer(SignalContainer other)
 {
     FrameSize           = other.FrameSize;
     FrameShift          = other.FrameShift;
     vSignal             = other.Signal;
     ShouldRebuildFrames = other.ShouldRebuildFrames;
     Frames = other.Frames == null ? null : new List <Frame>(other.Frames);
 }
        public List <FilterProcessResult> ProcessSignal(SignalContainer input)
        {
            List <FilterProcessResult> processResult = new List <FilterProcessResult>();

            foreach (FilterInfo filterInfo in Filters)
            {
                double[] processedSignal = filterInfo.Filter.ProcessSamples(input.Signal);
                processResult.Add(new FilterProcessResult(filterInfo.Band, processedSignal));
            }
            return(processResult);
        }
Beispiel #3
0
        public FeaturesContainer GetFeatures(SignalContainer signal)
        {
            IList <Frame>        frames   = signal.GetFrames();
            List <FrameFeatures> features = new List <FrameFeatures>();

            foreach (Frame frame in frames)
            {
                SignalContainer             extendedSignal         = GetSignalForFiltering(frame.Signal);
                IList <FilterProcessResult> extendedSignalChannels = FilterBankCore.ProcessSignal(extendedSignal);
                FilterBankCore.Reset();
                IList <FilterProcessResult> signalChannels = GetFilteredSignalsPart(extendedSignalChannels, frame.Bounds.Width);
                double[] channelsNormalizedEnergy          = GetChannelsEnergy(signalChannels);
                features.Add(new FrameFeatures(frame.Bounds, channelsNormalizedEnergy));
            }
            return(new FeaturesContainer(features));
        }
        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
            });
        }