fix: recover voice input after empty recognition result - #225
Conversation
|
🔍 OpenCodeReview found 2 issue(s) in this PR.
|
| var silentSegments = 0 | ||
| while (isActive) { | ||
| var outcome = VoiceDictationOutcome.REPORT | ||
| speech.startListening(language = speechLanguageTag(context)).collect { result -> |
There was a problem hiding this comment.
[bug · medium]
新しく導入された while (isActive) ループ内で speech.startListening(...).collect に例外処理がありません。SpeechRecognizerManager.startListening は newRecognizer.startListening(intent) のみ try/catch しており、SpeechRecognizer.createSpeechRecognizer の失敗やコールバック内の想定外例外がフローから送出されると、collect を抜けてそのまま scope.launch のコルーチンが異常終了します。scope は CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate) で CoroutineExceptionHandler を持たないため、未捕捉例外はアプリをクラッシュさせ、assistantState が LISTENING/THINKING のまま残るなどセッション状態が不正になります。ループ内で try/catch(または flow.catch)により showError を呼んでループを break するようにしてください。
| when (outcome) { | ||
| VoiceDictationOutcome.RESTART -> silentSegments++ | ||
| VoiceDictationOutcome.FINISH -> submitRecognizedText(partial) | ||
| VoiceDictationOutcome.REPORT -> showError(result.message) |
There was a problem hiding this comment.
[other · low]
REPORT 分岐では showError のみを呼び、直前の partialText.value がクリアされません。同じ書き換えの中で RESTART 分岐では明示的に partialText.value = "" としているため、エラー表示時も同様にクリアし、UI に古い部分認識テキストが残るのを防ぐとよいです。
Suggestion:
| VoiceDictationOutcome.REPORT -> showError(result.message) | |
| VoiceDictationOutcome.REPORT -> { | |
| partialText.value = "" | |
| showError(result.message) | |
| } |
Summary\n- remove the invalid language string passed to the boolean-only recognition option\n- submit a partial transcript when the recognizer returns an empty final bundle\n- retry transient empty voice segments instead of immediately showing an error\n\n## Verification\n- spotlessCheck passes\n- app unit test task is blocked in this environment because AAPT2 cannot start on aarch64