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