create static method

Future<Cheetah> create(
  1. String accessKey,
  2. String modelPath, {
  3. double endpointDuration = 1,
  4. dynamic enableAutomaticPunctuation = false,
})

Static creator for initializing Cheetah

accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/).

modelPath Path to the file containing model parameters.

endpointDuration (Optional) Duration of endpoint in seconds. A speech endpoint is detected when there is a chunk of audio (with a duration specified herein) after an utterance without any speech in it. Set duration to 0 to disable this. Default is 1 second. enableAutomaticPunctuation (Optional) Set to true to enable automatic punctuation insertion.

Throws a CheetahException if not initialized correctly

returns an instance of the Cheetah Speech-to-Text engine

Implementation

static Future<Cheetah> create(String accessKey, String modelPath,
    {double endpointDuration = 1, enableAutomaticPunctuation = false}) async {
  modelPath = await _tryExtractFlutterAsset(modelPath);

  try {
    Map<String, dynamic> result = Map<String, dynamic>.from(
        await _channel.invokeMethod(_NativeFunctions.CREATE.name, {
      'accessKey': accessKey,
      'modelPath': modelPath,
      'endpointDuration': endpointDuration,
      'enableAutomaticPunctuation': enableAutomaticPunctuation
    }));

    return Cheetah._(result['handle'], result['frameLength'],
        result['sampleRate'], result['version']);
  } on PlatformException catch (error) {
    throw cheetahStatusToException(error.code, error.message);
  } on Exception catch (error) {
    throw CheetahException(error.toString());
  }
}