Skip to content

Instantly share code, notes, and snippets.

@yektasarioglu
Created October 30, 2020 18:54
Show Gist options
  • Save yektasarioglu/2346c0c0b7f9a216b8c94501fd7a6286 to your computer and use it in GitHub Desktop.
Save yektasarioglu/2346c0c0b7f9a216b8c94501fd7a6286 to your computer and use it in GitHub Desktop.
initializeCallback()
private fun initializeCallback() {
asrRecognizer.setAsrListener(object : MLAsrListener {
override fun onResults(result: Bundle?) {
MediaPlayer.create(activity, R.raw.stop_record).start()
Log.i("ASRFragment", "result is ${result?.getString(MLAsrRecognizer.RESULTS_RECOGNIZED)}")
showResult(result?.getString(MLAsrRecognizer.RESULTS_RECOGNIZED) ?: "")
}
override fun onRecognizingResults(partialResult: Bundle?) {
Log.i("ASRFragment", "partialResult is ${partialResult?.getString(MLAsrRecognizer.RESULTS_RECOGNIZED)}")
showResult(partialResult?.getString(MLAsrRecognizer.RESULTS_RECOGNIZED) ?: "")
}
override fun onError(errorCode: Int, errorMessage: String?) {
Log.e("ASRFragment", "errorCode is $errorCode")
Log.e("ASRFragment", "errorMessage is $errorMessage")
}
override fun onStartListening() {
Log.i("ASRFragment", "onStartListening()")
MediaPlayer.create(activity, R.raw.start_record).start()
}
// Other callback events
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment