create static method
Static creator for initializing Cheetah
accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/).
modelPath Path to the file containing model parameters.
device (Optional) String representation of the device (e.g., CPU or GPU) to use. If set to best, the most
suitable device is selected automatically. If set to gpu, the engine uses the first
available GPU device. To select a specific GPU device, set this argument to gpu:${GPU_INDEX},
where ${GPU_INDEX} is the index of the target GPU. If set to cpu, the engine will run on the CPU
with the default number of threads. To specify the number of threads, set this argument to
cpu:${NUM_THREADS}, where ${NUM_THREADS} is the desired number of threads.
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,
{String device = "best", 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,
'device': device,
'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());
}
}