RecognitionConfig constructor

RecognitionConfig({
  1. required AudioEncoding encoding,
  2. required String languageCode,
  3. int? sampleRateHertz,
  4. int audioChannelCount = 1,
  5. bool enableSeparateRecognitionPerChannel = false,
  6. int maxAlternatives = 1,
  7. bool profanityFilter = false,
  8. List<SpeechContext> speechContexts = const [],
  9. bool enableWordTimeOffsets = false,
  10. bool enableAutomaticPunctuation = false,
  11. SpeakerDiarizationConfig? diarizationConfig,
  12. RecognitionMetadata? recognitionMetadata,
  13. RecognitionModel model = RecognitionModel.basic,
  14. bool useEnhanced = false,
  15. bool? enableSpokenPunctuation,
})

Provides information to the recognizer that specifies how to process the request.

Implementation

RecognitionConfig({
  required this.encoding,
  required this.languageCode,
  this.sampleRateHertz,
  this.audioChannelCount = 1,
  this.enableSeparateRecognitionPerChannel = false,
  this.maxAlternatives = 1,
  this.profanityFilter = false,
  this.speechContexts = const [],
  this.enableWordTimeOffsets = false,
  this.enableAutomaticPunctuation = false,
  this.diarizationConfig,
  this.recognitionMetadata,
  this.model = RecognitionModel.basic,
  this.useEnhanced = false,
  this.enableSpokenPunctuation,
})  : assert(encoding != AudioEncoding.AMR || sampleRateHertz == 8000,
          'sampleRateHertz must be 8000.'),
      assert(encoding != AudioEncoding.AMR_WB || sampleRateHertz == 16000,
          'sampleRateHertz must be 16000.'),
      assert(
          encoding != AudioEncoding.OGG_OPUS ||
              [8000, 12000, 16000, 24000, 48000].contains(sampleRateHertz),
          'sampleRateHertz must be one of 8000, 12000, 16000, 24000, or 48000.'),
      assert(
          encoding != AudioEncoding.SPEEX_WITH_HEADER_BYTE ||
              sampleRateHertz == 16000,
          'sampleRateHertz must be 16000.');