refactor(#1023): extract containsWakePhrase, resolve wake model from selected engine#1066
Open
lokhor wants to merge 2 commits into
Open
refactor(#1023): extract containsWakePhrase, resolve wake model from selected engine#1066lokhor wants to merge 2 commits into
lokhor wants to merge 2 commits into
Conversation
…o VoiceInputController interface
Debug APK readyCommit: Updated on each push. Removed when PR is merged or closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pure refactor — no behavioural changes. Extracts
containsWakePhrase()fromSherpaOnnxVoiceInputController.Companioninto a shared top-level utility and promotestranscribeBlocking()to theVoiceInputControllerinterface. Additionally, the wake-word verification engine now follows the user's selected online STT model instead of always using Zipformer.Changes — Round 1: Extraction
core/voice/.../WakeWordUtils.kt(new)fun String.containsWakePhrase()— same regex, public visibilitycore/voice/.../VoiceInputController.ktsuspend fun transcribeBlocking(pcm: ShortArray): String? = nullwith doc commentcore/voice/.../SherpaOnnxVoiceInputController.ktcontainsWakePhrase; changestranscribeBlockingtooverride suspend fun ... String?(null on failure)app/.../WakeWordService.ktvoiceInputController.transcribeBlocking(pcm)?.containsWakePhrase() ?: falseinstead of hardcoded Sherpa field; drops unused injectioncore/voice/.../SherpaOnnxVoiceInputControllerTest.ktcontainsWakePhrasetests + stale importcore/voice/.../WakeWordUtilsTest.kt(new)Changes — Round 2: Model selection for wake verification
transcribeBlocking()previously hardcodedSherpaSttModelSpec.WAKE_VERIFICATION_DEFAULT(Zipformer). It now resolves the user's selected engine and uses it when it's an online recognizer (Zipformer/Paraformer), falling back to Zipformer for offline-only models (SenseVoice/Whisper).core/voice/.../SherpaOnnxVoiceInputController.kttranscribeBlocking→resolveSpec()+ Online check; addedreleaseWakeRecognizer()to prevent native memory leak on engine switch;ensureWakeRecognizerBlockingdoc/log updatedfeature/settings/.../VoiceViewModel.ktresolveWakeEngineForDownload()helper; both download sites use it instead of hardcodingSherpaZipformercore/voice/.../SherpaSttModelSpec.ktWAKE_VERIFICATION_DEFAULTdoc updated to reflect fallback roledocs/SPECIFICATION.mdBehaviour matrix
Verification
:core:voice:test✓:app:testDebugUnitTest✓assembleDebug✓SherpaOnnxVoiceInputController.Companion.containsWakePhraseor the removed fieldCloses #1023