create static method
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.
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}) async {
modelPath = await _tryExtractFlutterAsset(modelPath);
try {
Map<String, dynamic> result =
Map<String, dynamic>.from(await _channel.invokeMethod('create', {
'accessKey': accessKey,
'modelPath': modelPath,
'enableAutomaticPunctuation': enableAutomaticPunctuation
}));
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());
}
}