app/src/main/java/com/example/jarvis_stts/JarvisService.kt aktualisiert
This commit is contained in:
@@ -8,6 +8,7 @@ import org.vosk.Recognizer
|
||||
import org.vosk.android.SpeechService
|
||||
import org.vosk.android.RecognitionListener
|
||||
import java.io.IOException
|
||||
import java.io.File
|
||||
|
||||
class JarvisService : Service(), RecognitionListener {
|
||||
|
||||
@@ -20,19 +21,21 @@ class JarvisService : Service(), RecognitionListener {
|
||||
|
||||
private fun setupVosk() {
|
||||
try {
|
||||
// Der Pfad muss zum Ordner zeigen, in den du das Modell entpackt hast
|
||||
val modelPath = getExternalFilesDir(null)?.absolutePath + "/model-de"
|
||||
// MainActivity entpackt nach "model", also greifen wir hier darauf zu:
|
||||
val modelPath = File(filesDir, "model").absolutePath
|
||||
|
||||
val model = Model(modelPath)
|
||||
|
||||
// WICHTIG: Wir limitieren den Recognizer auf das Wake-Word "jarvis"
|
||||
// Das erhöht die Erkennungsrate massiv!
|
||||
val recognizer = Recognizer(model, 16000f, "[\"jarvis\", \"[unk]\"]")
|
||||
// WICHTIG: Nutze hier "computer" ODER "jarvis",
|
||||
// je nachdem was du in der MainActivity definiert hast.
|
||||
val recognizer = Recognizer(model, 16000f, "[\"computer\", \"jarvis\", \"[unk]\"]")
|
||||
|
||||
speechService = SpeechService(recognizer, 16000f)
|
||||
speechService?.startListening(this)
|
||||
Log.d("JARVIS", "Service: Vosk hört jetzt zu...")
|
||||
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: Exception) {
|
||||
Log.e("JARVIS", "Service: Fehler beim Laden des Modells: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user