From 0bfb13f678b97e99295d5e374e57309701e9d7b5 Mon Sep 17 00:00:00 2001 From: adrienmalin <41926238+adrienmalin@users.noreply.github.com> Date: Thu, 6 Dec 2018 21:29:05 +0100 Subject: [PATCH] little changes --- .idea/caches/build_file_checksums.ser | Bin 548 -> 537 bytes .../java/adrienmalin/pingpoints/SttDialog.kt | 67 ++++++------------ .../main/res/layout-land/activity_match.xml | 3 +- app/src/main/res/layout/activity_match.xml | 6 +- app/src/main/res/layout/dialog_stt.xml | 8 ++- 5 files changed, 33 insertions(+), 51 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 70efde614d804122d23da0e44cccd16e0f880517..ed34ff93c3f22873acad0d6ff4a3760741859be4 100644 GIT binary patch delta 85 zcmV-b0IL6_1epYonFHOoB$1r?Ar6hOEI^y9s`i#H*Tr0_S#$s>Lpoelb7gXKTw!Es rZDEta0VEmJ9gNwJ0I~$>fC-rF_(Fbk01;<$VPtG&lYjvglM@0FPT?b6 delta 90 zcmV-g0Hyz#1f&FznF9jJ=8>HFEcJEJ`0TiS?g "Audio recording error" - SpeechRecognizer.ERROR_CLIENT -> "Client side error" - SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS -> "Insufficient permissions" - SpeechRecognizer.ERROR_NETWORK -> "Network error" - SpeechRecognizer.ERROR_NETWORK_TIMEOUT -> "Network timeout" - SpeechRecognizer.ERROR_NO_MATCH -> "No match" - SpeechRecognizer.ERROR_RECOGNIZER_BUSY -> "RecognitionService busy" - SpeechRecognizer.ERROR_SERVER -> "error from server" - SpeechRecognizer.ERROR_SPEECH_TIMEOUT -> "No speech input" - else -> "Didn't understand, please try again." - } - Log.d(LOG_TAG, "FAILED $errorMessage") - stt?.startListening(sttIntent) - } - - override fun onEvent(arg0: Int, arg1: Bundle?) { - Log.i(LOG_TAG, "onEvent") + override fun onRmsChanged(rmsdB: Float) { + minRms = min(rmsdB, minRms) + maxRms = max(rmsdB, maxRms) + if (minRms != maxRms) + icStt?.alpha = 0.5f + rmsdB / (2*(maxRms - minRms)) } override fun onPartialResults(data: Bundle) { - //Log.i(LOG_TAG, "onPartialResults") partialResultsTextView?.text = data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)[0] } - override fun onReadyForSpeech(arg0: Bundle?) { - Log.i(LOG_TAG, "onReadyForSpeech") - } - override fun onResults(data: Bundle) { - Log.i(LOG_TAG, "onResults"); val results: ArrayList = data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION) var understood = false @@ -86,16 +58,22 @@ class SttDialog : DialogFragment() { if (understood) break } if (!understood) { - partialResultsTextView?.text = getString(R.string.not_understood) - stt?.startListening(sttIntent) + onError(0) } } } } - override fun onRmsChanged(rmsdB: Float) { - //Log.i(LOG_TAG, "onRmsChanged: $rmsdB") + override fun onError(errorCode: Int) { + partialResultsTextView?.text = getString(R.string.not_understood) + stt?.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 onCreateDialog(savedInstanceState: Bundle?) = AlertDialog.Builder(activity).apply { @@ -104,6 +82,7 @@ class SttDialog : DialogFragment() { null ) partialResultsTextView = view.findViewById(R.id.partialResultTextView) + icStt = view.findViewById(R.id.icStt) setView(view) diff --git a/app/src/main/res/layout-land/activity_match.xml b/app/src/main/res/layout-land/activity_match.xml index 6e9eb6f..bc61c48 100644 --- a/app/src/main/res/layout-land/activity_match.xml +++ b/app/src/main/res/layout-land/activity_match.xml @@ -5,7 +5,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:keepScreenOn="true"> + android:layout_height="match_parent" + android:keepScreenOn="true"> + android:theme="@style/ScoreButton" android:layout_marginLeft="8dp"/>