Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
feat(call-session): add audio configuration error handling for STT/TTS setup
Durganshu Mishra33eb3baa5e3d
diff --git a/app/src/main/java/com/gotcha/service/CallSessionController.kt b/app/src/main/java/com/gotcha/service/CallSessionController.ktindex 59465e3..0aa87fd 100644--- a/app/src/main/java/com/gotcha/service/CallSessionController.kt+++ b/app/src/main/java/com/gotcha/service/CallSessionController.kt@@ -37,6 +37,7 @@ import kotlinx.coroutines.flow.asStateFlowimport kotlinx.coroutines.launchimport kotlinx.coroutines.withTimeoutOrNullimport kotlinx.serialization.json.JsonPrimitive+import okhttp3.HttpUrl.Companion.toHttpUrlOrNullenum class CallState { IDLE, STARTING, READY, LISTENING, THINKING, SPEAKING, WAITING_USER, PAUSED, ENDING }@@ -121,6 +122,18 @@ class CallSessionController(return false}+ val s = settingsRepository.load()+ val sttError = audioConfigError("Speech-to-text", s.sttProvider, s.sttApiBaseUrl, s.sttApiModel)+ if (sttError != null) {+ onError(sttError)+ return false+ }+ val ttsError = audioConfigError("Text-to-speech", s.ttsProvider, s.ttsApiBaseUrl, s.ttsApiModel)+ if (ttsError != null) {+ onError(ttsError)+ return false+ }+val newEngine = AgentEngine(appContext = appContext,events = this,@@ -464,6 +477,25 @@ class CallSessionController()}+ /**+ * Null when [provider]/[baseUrl]/[model] can actually be used for a call;+ * otherwise a user-facing reason. A call is voice-first end to end, so an+ * unconfigured or broken STT/TTS setup must block it before it starts+ * rather than surface only once the user is already mid-call.+ */+ private fun audioConfigError(label: String, provider: AudioProvider, baseUrl: String, model: String): String? =+ when (provider) {+ AudioProvider.NONE -> "$label is not configured. Set it up in Gotcha → Settings → Speech (TTS / STT)."+ AudioProvider.API -> when {+ baseUrl.isBlank() || baseUrl.trim().toHttpUrlOrNull() == null ->+ "$label API URL is missing or invalid. Fix it in Gotcha → Settings → Speech (TTS / STT)."+ model.isBlank() ->+ "$label API model is not selected. Choose one in Gotcha → Settings → Speech (TTS / STT)."+ else -> null+ }+ AudioProvider.ANDROID -> null+ }+private fun buildClient(): LLMClient? {val s = settingsRepository.load()return if (s.isConfigured) {