Skip to content

Instantly share code, notes, and snippets.

@DanishAmjad12
Last active October 10, 2021 13:37
Show Gist options
  • Save DanishAmjad12/89d0d801aaeede090b0e3f925489c440 to your computer and use it in GitHub Desktop.
Save DanishAmjad12/89d0d801aaeede090b0e3f925489c440 to your computer and use it in GitHub Desktop.
fun download() {
var modelIdentifier: DigitalInkRecognitionModelIdentifier? = null
try {
modelIdentifier =
DigitalInkRecognitionModelIdentifier.fromLanguageTag("zxx-Zsym-x-autodraw")
} catch (e: MlKitException) {
// language tag failed to parse, handle error.
}
model =
DigitalInkRecognitionModel.builder(modelIdentifier!!).build()
val remoteModelManager = RemoteModelManager.getInstance()
remoteModelManager.download(model, DownloadConditions.Builder().build())
.addOnSuccessListener {
Log.i("StrokeManager", "Model downloaded")
}
.addOnFailureListener { e: Exception ->
Log.e("StrokeManager", "Error while downloading a model: $e")
}
val recognizer: DigitalInkRecognizer =
DigitalInkRecognition.getClient(
DigitalInkRecognizerOptions.builder(model).build()
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment