app/src/main/java/com/example/jarvis_stts/JarviceService.kt aktualisiert
This commit is contained in:
@@ -143,10 +143,14 @@ class JarvisService : Service(), RecognitionListener {
|
|||||||
val json = JSONObject(hypothesis)
|
val json = JSONObject(hypothesis)
|
||||||
val partialText = json.optString("partial").lowercase().trim()
|
val partialText = json.optString("partial").lowercase().trim()
|
||||||
|
|
||||||
// Regex \b bedeutet "Wortgrenze". Er sucht nach dem eigenständigen Wort.
|
// HIER: Lass dir mal ausgeben, was er eigentlich versteht!
|
||||||
// Verhindert Reaktionen auf Fantasiewörter, in denen die Silben vorkommen.
|
if (partialText.isNotEmpty()) {
|
||||||
if (Regex("\\b(jarvis)\\b").containsMatchIn(partialText)) {
|
Log.d("JARVIS_DEBUG", "Vosk hört: $partialText")
|
||||||
Log.d("JARVIS", "WAKE WORD IM TEXT ERKANNT: $partialText")
|
}
|
||||||
|
|
||||||
|
// Unser Regex-Check (den passen wir gleich an)
|
||||||
|
if (Regex("\\b(jarvis|computer)\\b").containsMatchIn(partialText)) {
|
||||||
|
Log.d("JARVIS", "WAKE WORD ERKANNT: $partialText")
|
||||||
triggerJarvis()
|
triggerJarvis()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user