create static method

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

Static creator for initializing Leopard

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

modelPath Path to the file containing model parameters.

enableAutomaticPunctuation (Optional) Set to true to enable automatic punctuation insertion.

enableDiarization (Optional) Set to true to enable speaker diarization, which allows Leopard to differentiate speakers as part of the transcription process. Word metadata will include a speaker_tag to identify unique speakers.

Throws a LeopardException if not initialized correctly

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

Implementation

static Future<Leopard> create(String accessKey, String modelPath,
    {enableAutomaticPunctuation = false, enableDiarization = 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,
      'enableAutomaticPunctuation': enableAutomaticPunctuation,
      'enableDiarization': enableDiarization
    }));

    return Leopard._(
        result['handle'], result['sampleRate'], result['version']);
  } on PlatformException catch (error) {
    throw leopardStatusToException(error.code, error.message);
  } on Exception catch (error) {
    throw LeopardException(error.toString());
  }
}