RecognitionConfig constructor
RecognitionConfig({
- required AudioEncoding encoding,
- required String languageCode,
- int? sampleRateHertz,
- int audioChannelCount = 1,
- bool enableSeparateRecognitionPerChannel = false,
- int maxAlternatives = 1,
- bool profanityFilter = false,
- List<
SpeechContext> speechContexts = const [], - bool enableWordTimeOffsets = false,
- bool enableAutomaticPunctuation = false,
- SpeakerDiarizationConfig? diarizationConfig,
- RecognitionMetadata? recognitionMetadata,
- RecognitionModel model = RecognitionModel.basic,
- bool useEnhanced = false,
- 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.');