Exemplo n.º 1
0
VXIMap * GrammarManager::GetRecordProperties(const PropertyList & props,
                                             int timeout) const
{
  VXIMapHolder m;
  if (m.GetValue() == NULL) throw VXIException::OutOfMemory();

  // (1) Retrieve flattened property list.
  props.GetProperties(m);

  // (2) Convert & manipulate the properties.
  const VXIchar * j;
  VXIint time;

  // (2.1) Completion timeout
  j = props.GetProperty(GrammarManager::MaxTime);
  if (j != NULL && props.ConvertTimeToMilliseconds(log, j, time))
    AddParamValue(m, REC_MAX_RECORDING_TIME, time);

  // (2.2) Final silence
  j = props.GetProperty(GrammarManager::FinalSilence);
  if (j != NULL && props.ConvertTimeToMilliseconds(log, j, time))
    AddParamValue(m, REC_TIMEOUT_COMPLETE, time);

  // (2.3) Type
  j = props.GetProperty(GrammarManager::RecordingType);
  if (j != NULL)
    AddParamValue(m, REC_RECORD_MIME_TYPE, j);

  // (2.4) DTMF terminates record?
  j = props.GetProperty(GrammarManager::DTMFTerm);
  if (j != NULL) {
    int dtmfterm;
    if (vxistring(j) == L"false")
      dtmfterm = 0;
    else
      dtmfterm = 1;
    
    AddParamValue(m, REC_TERMINATED_ON_DTMF, dtmfterm);
  }

  // (2.5) Timeout settings
  if (timeout == -1) {
    j = props.GetProperty(PROP_TIMEOUT);
    if (j != NULL)
      PropertyList::ConvertTimeToMilliseconds(log, j, timeout);
  }

  if (timeout != -1) {
    AddParamValue(m, REC_DTMF_TIMEOUT, timeout);
    AddParamValue(m, REC_TIMEOUT, timeout);
  }

  // (3) Done

  return m.Release();
}
Exemplo n.º 2
0
VXIMap * GrammarManager::GetRecProperties(const PropertyList & props,
                                          int timeout) const
{
  VXIMapHolder m;
  if (m.GetValue() == NULL) throw VXIException::OutOfMemory();

  // (1) Retrieve flattened property list.
  props.GetProperties(m);

  // (2) Convert & manipulate the properties.
  // TBD #pragma message ("GrammarManager::GetRecProperties - handle REC_RESULT_SAVE_WAVEFORM ???")
  // TBD #pragma message ("GrammarManager::GetRecProperties - handle REC_RESULT_NBEST_SIZE ???")

  const VXIchar * j;
  VXIint time;
  VXIflt32 fraction;

  // (2.1) Language
  j = props.GetProperty(PropertyList::Language);
  if (j != NULL)
    AddParamValue(m, REC_LANGUAGE, j);

  // (2.2) Completion timeout
  j = props.GetProperty(PROP_COMPLETETIME);
  if (j != NULL && props.ConvertTimeToMilliseconds(log, j, time))
    AddParamValue(m, REC_TIMEOUT_COMPLETE, time);

  // (2.3) Incompletion timeout
  j = props.GetProperty(PROP_INCOMPLETETIME);
  if (j != NULL && props.ConvertTimeToMilliseconds(log, j, time))
    AddParamValue(m, REC_TIMEOUT_INCOMPLETE, time);

  // (2.4) Inter-Digit timeout
  j = props.GetProperty(PROP_INTERDIGITTIME);
  if (j != NULL && props.ConvertTimeToMilliseconds(log, j, time))
    AddParamValue(m, REC_DTMF_TIMEOUT_INTERDIGIT, time);

  // (2.5) Inter-Digit timeout
  j = props.GetProperty(PROP_TERMTIME);
  if (j != NULL && props.ConvertTimeToMilliseconds(log, j, time))
    AddParamValue(m, REC_DTMF_TIMEOUT_TERMINATOR, time);

  // (2.6) Confidence level
  j = props.GetProperty(PROP_CONFIDENCE);
  if (j != NULL && props.ConvertValueToFraction(log, j, fraction))
    AddParamValue(m, REC_CONFIDENCE_LEVEL, fraction);

  // (2.7) Barge-in sensitivity level
  j = props.GetProperty(PROP_SENSITIVITY);
  if (j != NULL && props.ConvertValueToFraction(log, j, fraction))
    AddParamValue(m, REC_SENSITIVITY, fraction);

  // (2.8) Performance tradeoff - speed vs. accuracy
  j = props.GetProperty(PROP_SPEEDVSACC);
  if (j != NULL && props.ConvertValueToFraction(log, j, fraction))
    AddParamValue(m, REC_SPEED_VS_ACCURACY, fraction);
  
  // (2.9) DTMF terminator character
  j = props.GetProperty(PROP_TERMCHAR);
  if ((j != NULL) && (j[0] != L'\0')) {
    if (wcslen(j) == 1)
      AddParamValue(m, REC_DTMF_TERMINATOR_CHAR, j);
    else {
      log.StartDiagnostic(0) << L"GrammarManager::GetRecProperties - "
        L"Unable to set " << REC_DTMF_TERMINATOR_CHAR << L" from value \"" <<
        j << L"\".  Defaulting to '#'.";
      log.EndDiagnostic();
      // Should we use the default, or rather not set anything ?
      AddParamValue(m, REC_DTMF_TERMINATOR_CHAR, L"#");
    }
  }
  
  // (2.10) Input modes
  int mode = REC_INPUT_MODE_DTMF_SPEECH;
  j = props.GetProperty(PROP_INPUTMODES);
  if (j != NULL) { 
    vxistring value(j);
    if (value == L"voice dtmf" || value == L"dtmf voice")
      mode = REC_INPUT_MODE_DTMF_SPEECH;
    else if (value == L"voice")
      mode = REC_INPUT_MODE_SPEECH;
    else if (value == L"dtmf")
      mode = REC_INPUT_MODE_DTMF;
    else {
      log.StartDiagnostic(0) << L"GrammarManager::GetRecProperties - "
        L"Unable to set " << REC_INPUT_MODES << L" from value \"" << value <<
        L"\".";
      log.EndDiagnostic();
    }
  }
  AddParamValue(m, REC_INPUT_MODES, mode);

  // (2.11) Timeout settings
  if (timeout == -1) {
    j = props.GetProperty(PROP_TIMEOUT);
    if (j != NULL)
      PropertyList::ConvertTimeToMilliseconds(log, j, timeout);
  }

  if (timeout != -1) {
    AddParamValue(m, REC_DTMF_TIMEOUT, timeout);
    AddParamValue(m, REC_TIMEOUT, timeout);
  }


  // (3) Done

  return m.Release();
}