parse stt on partial results

This commit is contained in:
adrienmalin 2018-12-15 23:51:25 +01:00
parent f6842a3832
commit a86a57889d
2 changed files with 11 additions and 13 deletions

2
.idea/misc.xml generated
View File

@ -29,7 +29,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -46,19 +46,14 @@ class SttDialog : DialogFragment() {
} }
override fun onPartialResults(data: Bundle) { override fun onPartialResults(data: Bundle) {
data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)?.let { results ->
if (results.isNotEmpty())
partialResultsTextView?.text = results[0]
}
}
override fun onResults(data: Bundle) {
data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)?.let { results ->
matchActivity?.apply { matchActivity?.apply {
matchModel?.apply { matchModel?.apply {
data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)?.let { results ->
for (result in results) { for (result in results) {
partialResultsTextView?.text = result
for (player in players) { for (player in players) {
if (player.pattern?.matcher(result)?.find() == true) { if (player.pattern?.matcher(result)?.find() == true) {
stt?.stopListening()
dismiss() dismiss()
updateScore(player) updateScore(player)
updateUI() updateUI()
@ -66,12 +61,15 @@ class SttDialog : DialogFragment() {
} }
} }
} }
}
}
}
}
override fun onResults(data: Bundle) {
partialResultsTextView?.text = getString(R.string.not_understood) partialResultsTextView?.text = getString(R.string.not_understood)
onError(ERROR_NOT_UNDERSTOOD) onError(ERROR_NOT_UNDERSTOOD)
} }
}
}
}
override fun onEndOfSpeech() {} override fun onEndOfSpeech() {}