validate method

void validate()

Implementation

void validate() {
  final effectiveSampleRate = hasSampleRate() ? sampleRate : 16000;
  if (effectiveSampleRate < 16000 || effectiveSampleRate > 16000) {
    throw SDKException.validationFailed(
      'sample_rate must be in 16000...16000 (got $effectiveSampleRate)',
      fieldPath: 'DiarizationOptions.sample_rate',
    );
  }
  final effectiveChannels = hasChannels() ? channels : 1;
  if (effectiveChannels < 1 || effectiveChannels > 1) {
    throw SDKException.validationFailed(
      'channels must be in 1...1 (got $effectiveChannels)',
      fieldPath: 'DiarizationOptions.channels',
    );
  }
  final effectiveThreshold = hasThreshold() ? threshold : 0.5;
  if (!effectiveThreshold.isFinite || effectiveThreshold < 0.0 || effectiveThreshold > 1.0) {
    throw SDKException.validationFailed(
      'threshold must be in 0.0...1.0 (got $effectiveThreshold)',
      fieldPath: 'DiarizationOptions.threshold',
    );
  }
  if (minimumDurationMs < Int64(0)) {
    throw SDKException.validationFailed(
      'minimum_duration_ms must be >= 0 (got $minimumDurationMs)',
      fieldPath: 'DiarizationOptions.minimum_duration_ms',
    );
  }
  if (mergeGapMs < Int64(0)) {
    throw SDKException.validationFailed(
      'merge_gap_ms must be >= 0 (got $mergeGapMs)',
      fieldPath: 'DiarizationOptions.merge_gap_ms',
    );
  }
  if (hasMaxSpeakers() && (maxSpeakers < 1)) {
    throw SDKException.validationFailed(
      'max_speakers must be >= 1 (got $maxSpeakers)',
      fieldPath: 'DiarizationOptions.max_speakers',
    );
  }
}