fix(asr): keep recordings when streaming recognition fails or stalls

- Keep recording after a streaming ASR error and retry the captured PCM
  through batch ASR before reporting a failure.
- Treat an expired ASR wait as a stall so batch fallback still runs.
- Prime the managed Volcengine stream on mic touch and adopt it only while
  fresh and open.
- Auto-scroll the live transcript to the newest recognized text.
This commit is contained in:
2026-10-20 20:05:08 +02:00
parent f7a031cc1d
commit be56d2210c
9 changed files with 518 additions and 20 deletions
@@ -10,13 +10,18 @@ public enum UtteranceBatchFallbackPolicy {
public static let defaultCharacterAdvantage = UtteranceTranscriptGuard.defaultPartialAdvantage
/// True when chunked output likely lost trailing content vs the live partial.
///
/// `recognitionStalled` means the ASR wait expired before the recognizer
/// finished (e.g. the streaming socket went quiet). That is a failure, not
/// silence, so the captured PCM still deserves a batch attempt.
public static func shouldRunBatchFallback(
stitchedFinal: String,
partialSnapshot: String,
recognitionFailed: Bool = false,
recognitionStalled: Bool = false,
minimumCharacterAdvantage: Int = defaultCharacterAdvantage
) -> Bool {
if recognitionFailed { return true }
if recognitionFailed || recognitionStalled { return true }
let final = stitchedFinal.trimmingCharacters(in: .whitespacesAndNewlines)
let partial = partialSnapshot.trimmingCharacters(in: .whitespacesAndNewlines)