




















@@ -157,7 +157,6 @@ class TalkModeManager internal constructor(
157157private val completedRunStates = LinkedHashMap<String, Boolean>()
158158private val completedRunTexts = LinkedHashMap<String, String>()
159159private var configLoaded = false
160-private var executionMode = TalkModeExecutionMode.Native
161160private val startGeneration = AtomicLong(0L)
162161163162 @Volatile private var realtimeSessionId: String? = null
@@ -526,53 +525,17 @@ class TalkModeManager internal constructor(
526525try {
527526 ensureConfigLoaded()
528527if (generation != startGeneration.get() || !_isEnabled.value || stopRequested) return@launch
529-if (executionMode == TalkModeExecutionMode.RealtimeRelay) {
530- startRealtimeRelay(generation)
531- } else {
532- startNativeRecognition(generation)
533- }
528+ startRealtimeRelay(generation)
534529 } catch (err: Throwable) {
535530if (err is CancellationException) return@launch
536531_statusText.value = "Start failed: ${err.message ?: err::class.simpleName}"
537532Log.w(tag, "start failed: ${err.message ?: err::class.simpleName}")
538-if (executionMode == TalkModeExecutionMode.RealtimeRelay) {
539- stopRealtimeRelay(closeSession = false, preserveStatus = true)
540- disableRealtimeModeAndNotifyOwner()
541- }
533+ stopRealtimeRelay(closeSession = false, preserveStatus = true)
534+ disableRealtimeModeAndNotifyOwner()
542535 }
543536 }
544537 }
545538546-private suspend fun startNativeRecognition(generation: Long) {
547- withContext(Dispatchers.Main) {
548-if (generation != startGeneration.get()) return@withContext
549-if (!_isEnabled.value || stopRequested) return@withContext
550-if (_isListening.value) return@withContext
551-Log.d(tag, "start native")
552-553-if (!SpeechRecognizer.isRecognitionAvailable(context)) {
554-_statusText.value = "Speech recognizer unavailable"
555-Log.w(tag, "speech recognizer unavailable")
556-return@withContext
557- }
558-559-val micOk =
560-ContextCompat.checkSelfPermission(context, Manifest.permission.RECORD_AUDIO) ==
561-PackageManager.PERMISSION_GRANTED
562-if (!micOk) {
563-_statusText.value = "Microphone permission required"
564-Log.w(tag, "microphone permission required")
565-return@withContext
566- }
567-568- recognizer?.destroy()
569- recognizer = SpeechRecognizer.createSpeechRecognizer(context).also { it.setRecognitionListener(listener) }
570- startListeningInternal(markListening = true)
571- startSilenceMonitor()
572-Log.d(tag, "listening")
573- }
574- }
575-576539private fun stop() {
577540 stopRequested = true
578541 finalizeInFlight = false
@@ -2221,11 +2184,9 @@ class TalkModeManager internal constructor(
22212184val parsed = TalkModeGatewayConfigParser.parse(root?.get("config").asObjectOrNull())
22222185 silenceWindowMs = parsed.silenceTimeoutMs
22232186 parsed.interruptOnSpeech?.let { interruptOnSpeech = it }
2224- executionMode = parsed.executionMode
22252187 configLoaded = true
22262188 } catch (_: Throwable) {
22272189 silenceWindowMs = TalkDefaults.defaultSilenceTimeoutMs
2228- executionMode = TalkModeExecutionMode.Native
22292190 configLoaded = false
22302191 }
22312192 }
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。