small changes

This commit is contained in:
adrienmalin 2018-12-17 17:23:17 +01:00
parent 0dcef96194
commit 6a51441c0f
8 changed files with 11 additions and 12 deletions

Binary file not shown.

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_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" 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">

Binary file not shown.

View File

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"2.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":5,"versionName":"2.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

View File

@ -30,7 +30,7 @@ class MatchActivity : AppCompatActivity() {
inner class SttAfterTts : UtteranceProgressListener() { inner class SttAfterTts : UtteranceProgressListener() {
override fun onDone(id: String) { override fun onDone(id: String) {
SttDialog().show( supportFragmentManager, "SttDialog") SttDialog().show(supportFragmentManager, "SttDialog")
} }
override fun onStart(id: String) {} override fun onStart(id: String) {}
@ -69,7 +69,10 @@ class MatchActivity : AppCompatActivity() {
sttEnabled = getBooleanExtra("enableSTT", false) sttEnabled = getBooleanExtra("enableSTT", false)
saveState() saveState()
if (ttsEnabled) tts = TextToSpeech(this@MatchActivity, WaitForTtsInit()) if (ttsEnabled) {
tts = TextToSpeech(this@MatchActivity, WaitForTtsInit())
if (sttEnabled) tts?.setOnUtteranceProgressListener(SttAfterTts())
}
if (!sttEnabled) showPopUp(getString(R.string.button_hint)) if (!sttEnabled) showPopUp(getString(R.string.button_hint))
} }
} }
@ -127,10 +130,7 @@ class MatchActivity : AppCompatActivity() {
if (matchPoint) scoreSpeech += getString(R.string.match_point) if (matchPoint) scoreSpeech += getString(R.string.match_point)
say(scoreSpeech) say(scoreSpeech)
} }
if (sttEnabled) { if (sttEnabled and !ttsEnabled) SttDialog().show(supportFragmentManager, "SttDialog")
if (ttsEnabled) tts?.setOnUtteranceProgressListener(SttAfterTts())
else SttDialog().show(supportFragmentManager, "SttDialog")
}
} }
} }
} }

View File

@ -1,9 +1,7 @@
package adrienmalin.pingpoints package adrienmalin.pingpoints
import java.util.regex.Pattern
data class Player ( data class Player (
var name: String, var name: String,
var score: Int, var score: Int,
var pattern: Pattern? = null var soundex:String? = null
) )

View File

@ -99,10 +99,11 @@ class SttDialog : DialogFragment() {
players[1].name players[1].name
) )
sttIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply { sttIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM) putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH)
putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10) putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10)
putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true) putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true)
putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true) putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true)
putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 30000)
} }
stt = SpeechRecognizer.createSpeechRecognizer(activity).apply { stt = SpeechRecognizer.createSpeechRecognizer(activity).apply {
setRecognitionListener(SttListener()) setRecognitionListener(SttListener())