Exemplo n.º 1
0
        public List <IData> CollectOutput(BaseDataProcessor dataProc)
        {
            dataProc.Predecessor = this;

            var output = new List <IData>();

            IData d;

            while ((d = dataProc.GetData()) != null)
            {
                output.Add(d);
            }

            return(output);
        }
Exemplo n.º 2
0
        private void InitDataProcessors()
        {
            try
            {
                var featParams = Loader.Properties;
                SelectedDataProcessors = new List <IDataProcessor>();

                double lowFreq   = double.Parse(featParams["-lowerf"], CultureInfo.InvariantCulture.NumberFormat);
                double hiFreq    = double.Parse(featParams["-upperf"], CultureInfo.InvariantCulture.NumberFormat);
                int    numFilter = int.Parse(featParams["-nfilt"], CultureInfo.InvariantCulture.NumberFormat);

                // TODO: should not be there, but for now me must preserve
                // backward compatibility with the legacy code.
                if (Loader is KaldiLoader)
                {
                    FilterBank = new MelFrequencyFilterBank2(lowFreq, hiFreq, numFilter);
                }
                else
                {
                    FilterBank = new MelFrequencyFilterBank(lowFreq, hiFreq, numFilter);
                }

                SelectedDataProcessors.Add(FilterBank);

                if ((featParams.get("-remove_noise") == null) || (featParams.get("-remove_noise").Equals("yes")))
                {
                    Denoise = new Denoise(
                        typeof(Denoise).GetField <S4Double>("LambdaPower").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("LambdaA").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("LambdaB").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("LambdaT").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("MuT").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("MaxGain").DefaultValue,
                        typeof(Denoise).GetField <S4Integer>("SmoothWindow").DefaultValue);

                    // denoise.newProperties();
                    Denoise.Predecessor = SelectedDataProcessors[SelectedDataProcessors.Count - 1];
                    SelectedDataProcessors.Add(Denoise);
                }

                if ((featParams.get("-transform") != null) &&
                    (featParams.get("-transform").Equals("dct")))
                {
                    Dct = new DiscreteCosineTransform2(
                        numFilter,
                        typeof(DiscreteCosineTransform).GetField <S4Integer>("PropCepstrumLength").DefaultValue);
                }
                else if ((featParams.get("-transform") != null) &&
                         (featParams.get("-transform").Equals("kaldi")))
                {
                    Dct = new KaldiDiscreteCosineTransform(numFilter, typeof(DiscreteCosineTransform).GetField <S4Integer>("PropCepstrumLength").DefaultValue);
                }
                else
                {
                    Dct = new DiscreteCosineTransform(numFilter, typeof(DiscreteCosineTransform).GetField <S4Integer>("PropCepstrumLength").DefaultValue);
                }
                Dct.Predecessor = SelectedDataProcessors[SelectedDataProcessors.Count - 1];
                SelectedDataProcessors.Add(Dct);

                if (featParams.get("-lifter") != null)
                {
                    Lifter             = new Lifter(int.Parse(featParams.get("-lifter"), CultureInfo.InvariantCulture.NumberFormat));
                    Lifter.Predecessor = SelectedDataProcessors[SelectedDataProcessors.Count - 1];
                    SelectedDataProcessors.Add(Lifter);
                }


                this.LogInfo("Cepstrum component auto-configured as follows: " + ToString());
            }
            catch (Exception ex)
            {
                throw new RuntimeException(ex);
            }
        }