Пример #1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * edu.cmu.sphinx.util.props.Configurable#newProperties(edu.cmu.sphinx.util
  * .props.PropertySheet)
  */
 @Override
 public void newProperties(PropertySheet ps) throws PropertyException {
   super.newProperties(ps);
   loader = (Loader) ps.getComponent(PROP_LOADER);
   try {
     loader.load();
   } catch (IOException e) {
     throw new PropertyException(e);
   }
   initDataProcessors();
 }
Пример #2
0
 public AutoCepstrum(Loader loader) throws IOException {
   initLogger();
   this.loader = loader;
   loader.load();
   initDataProcessors();
 }
Пример #3
0
  private void initDataProcessors() {
    try {
      Properties featParams = loader.getProperties();
      selectedDataProcessors = new ArrayList<DataProcessor>();
      filterBank =
          new MelFrequencyFilterBank(
              Double.parseDouble((String) featParams.get("-lowerf")),
              Double.parseDouble((String) featParams.get("-upperf")),
              Integer.parseInt((String) featParams.get("-nfilt")));
      selectedDataProcessors.add(filterBank);

      if ((featParams.get("-remove_noise") != null)
          && (featParams.get("-remove_noise").equals("yes"))) {
        denoise =
            new Denoise(
                Denoise.class.getField("LAMBDA_POWER").getAnnotation(S4Double.class).defaultValue(),
                Denoise.class.getField("LAMBDA_A").getAnnotation(S4Double.class).defaultValue(),
                Denoise.class.getField("LAMBDA_B").getAnnotation(S4Double.class).defaultValue(),
                Denoise.class.getField("LAMBDA_T").getAnnotation(S4Double.class).defaultValue(),
                Denoise.class.getField("MU_T").getAnnotation(S4Double.class).defaultValue(),
                Denoise.class
                    .getField("EXCITATION_THRESHOLD")
                    .getAnnotation(S4Double.class)
                    .defaultValue(),
                Denoise.class.getField("MAX_GAIN").getAnnotation(S4Double.class).defaultValue(),
                Denoise.class
                    .getField("SMOOTH_WINDOW")
                    .getAnnotation(S4Integer.class)
                    .defaultValue());
        // denoise.newProperties();
        denoise.setPredecessor(selectedDataProcessors.get(selectedDataProcessors.size() - 1));
        selectedDataProcessors.add(denoise);
      }

      if ((featParams.get("-transform") != null) && (featParams.get("-transform").equals("dct"))) {
        dct =
            new DiscreteCosineTransform2(
                DiscreteCosineTransform.class
                    .getField("PROP_NUMBER_FILTERS")
                    .getAnnotation(S4Integer.class)
                    .defaultValue(),
                DiscreteCosineTransform.class
                    .getField("PROP_CEPSTRUM_LENGTH")
                    .getAnnotation(S4Integer.class)
                    .defaultValue());
      } else {
        dct =
            new DiscreteCosineTransform(
                DiscreteCosineTransform.class
                    .getField("PROP_NUMBER_FILTERS")
                    .getAnnotation(S4Integer.class)
                    .defaultValue(),
                DiscreteCosineTransform.class
                    .getField("PROP_CEPSTRUM_LENGTH")
                    .getAnnotation(S4Integer.class)
                    .defaultValue());
      }
      dct.setPredecessor(selectedDataProcessors.get(selectedDataProcessors.size() - 1));
      selectedDataProcessors.add(dct);

      if (featParams.get("-lifter") != null) {
        lifter = new Lifter(Integer.parseInt((String) featParams.get("-lifter")));
        lifter.setPredecessor(selectedDataProcessors.get(selectedDataProcessors.size() - 1));
        selectedDataProcessors.add(lifter);
      }
      logger.info("Cepstrum component auto-configured as follows: " + toString());
    } catch (NoSuchFieldException exc) {
      throw new RuntimeException(exc);
    }
  }