Fix STT stopping after 5s of silence

This commit is contained in:
adrienmalin 2018-12-07 17:10:50 +01:00
parent fcb2b90999
commit 9d9eaef88d
2 changed files with 7 additions and 5 deletions

View File

@ -56,6 +56,7 @@ class SttDialog : DialogFragment() {
}
}
}
partialResultsTextView?.text = getString(R.string.not_understood)
onError(ERROR_NOT_UNDERSTOOD)
}
}
@ -63,15 +64,17 @@ class SttDialog : DialogFragment() {
}
override fun onError(errorCode: Int) {
partialResultsTextView?.text = getString(R.string.not_understood)
stt?.startListening(sttIntent)
stt = SpeechRecognizer.createSpeechRecognizer(activity).apply {
setRecognitionListener(SttListener())
startListening(sttIntent)
}
}
override fun onEvent(arg0: Int, arg1: Bundle?) {}
override fun onReadyForSpeech(arg0: Bundle?) {}
override fun onBeginningOfSpeech() {}
override fun onBufferReceived(buffer: ByteArray?) {}
override fun onEndOfSpeech() {}
override fun onEvent(arg0: Int, arg1: Bundle?) {}
}
override fun onCreateDialog(savedInstanceState: Bundle?) = AlertDialog.Builder(activity).apply {
@ -115,5 +118,4 @@ class SttDialog : DialogFragment() {
stt?.stopListening()
stt?.destroy()
}
}

View File

@ -41,7 +41,7 @@ class VictoryActivity : AppCompatActivity() {
)
)
previousMatches = previousMatch.getString("previousMatches", "")
previousMatches = previousMatch.getString("previousMatches", "") ?: ""
previousMatch.edit().apply {
putString(
"previousMatches",