app/src/main/java/com/example/jarvis_stts/MainActivity.kt aktualisiert
This commit is contained in:
@@ -106,7 +106,8 @@ class MainActivity : AppCompatActivity(), RecognitionListener, TextToSpeech.OnIn
|
||||
try {
|
||||
if (voskModel == null) return
|
||||
// Wir horchen auf "jarvis". [unk] lässt unbekannte Wörter zu.
|
||||
val rec = Recognizer(voskModel, 16000.0f, "[\"jarvis\", \"[unk]\"]")
|
||||
val rec = Recognizer(voskModel, 16000.0f, "[\"computer\", \"[unk]\"]")
|
||||
//val rec = Recognizer(voskModel, 16000.0f, "[\"jarvis\", \"[unk]\"]")
|
||||
voskService = SpeechService(rec, 16000.0f)
|
||||
voskService?.startListening(this)
|
||||
runOnUiThread { tvStatus.text = "Bereit (Warte auf 'Jarvis')" }
|
||||
@@ -117,9 +118,12 @@ class MainActivity : AppCompatActivity(), RecognitionListener, TextToSpeech.OnIn
|
||||
|
||||
// --- Vosk RecognitionListener ---
|
||||
override fun onPartialResult(hypothesis: String) {
|
||||
// Vosk liefert JSON, z.B. {"partial" : "jarvis"}
|
||||
if (hypothesis.contains("jarvis", ignoreCase = true)) {
|
||||
voskService?.stop() // Mikrofon für Google frei machen
|
||||
// Diese Zeile zeigt dir live im Logcat, was Vosk gerade verstanden hat:
|
||||
Log.d("JARVIS", "Vosk hört: $hypothesis")
|
||||
|
||||
// Testweise auf "computer" hören
|
||||
if (hypothesis.contains("computer", ignoreCase = true)) {
|
||||
voskService?.stop()
|
||||
startVoiceInput()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user