This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
configureEnginePreferences() | |
initializeEngine() | |
initializeCallback() | |
initializeUI() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun configureEnginePreferences() { | |
ttsConfig = MLTtsConfig() | |
.setLanguage(ENGLISH_LANGUAGE_CODE) | |
.setPerson(ENGLISH_LANGUAGE_CODE + FEMALE_SPEAKER_CODE) | |
.setSpeed(1f) | |
.setVolume(1f) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun initializeEngine() { | |
ttsEngine = MLTtsEngine(ttsConfig) | |
} | |
private fun initializeCallback() { | |
ttsCallback = object : MLTtsCallback { // Whole MLTtsCallback implementation } | |
ttsEngine.setTtsCallback(ttsCallback) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun initializeUI() { | |
binding?.apply { | |
voiceSpeedSlider.addOnChangeListener { _, value, _ -> | |
voiceSpeed = value | |
isDefaultSpeedValueExceeded = value > 1f | |
} | |
maleRadioButton.setOnClickListener { | |
isMale = true | |
languageRadioGroup.clearCheck() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
initializeASR() | |
initializeUI() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun initializeASRRecognizer() { | |
asrRecognizer = MLAsrRecognizer.createAsrRecognizer(activity) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun initializeUI() { | |
binding.apply { | |
withPickUpUIRadioButton.setOnClickListener { isPickUpUI = true } | |
withoutPickUpUIRadioButton.setOnClickListener { isPickUpUI = false } | |
asrButton.setOnClickListener { | |
if (isPickUpUI) startRecognizeWithSpeechPickupUI() | |
else startRecognizeWithoutSpeechPickupUI() | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun startRecognizeWithSpeechPickupUI() { | |
val intent = Intent(activity, MLAsrCaptureActivity::class.java) | |
.putExtra(MLAsrCaptureConstants.LANGUAGE, ENGLISH_LANGUAGE_CODE) | |
.putExtra(MLAsrCaptureConstants.FEATURE, MLAsrCaptureConstants.FEATURE_WORDFLUX) | |
startActivityForResult(intent, ASR_RESULT_CODE) | |
} | |
private fun startRecognizeWithoutSpeechPickupUI() { | |
val intent = Intent(MLAsrConstants.ACTION_HMS_ASR_SPEECH) | |
.putExtra(MLAsrCaptureConstants.LANGUAGE, ENGLISH_LANGUAGE_CODE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate() { | |
super.onCreate() | |
MLApplication.getInstance().apiKey = BuildConfig.HMS_API_KEY | |
} |