Repository navigation
Plugin 1.1.0: recognition 3–4× faster (window fitting the recording, one thread pool, CPU variants), no dictated text in the log - #6
Open
4di-hello wants to merge 16 commits into
Conversation
…ol, whisper.cpp 1.9.6 - Whisper computed a full 30 s window (1500 audio frames) even for 3 s of speech. Below 30 s the window now fits the audio with some room (audio_ctx). - One thread pool for the CPU backend on the fastest cores, kept while the process runs (patch to whisper.cpp, applied by CMake). Without it ggml starts and ends threads for every graph, so for every decoded token. - whisper.cpp 1.7.4 -> 1.9.6, OpenMP stays off. - The log has only numbers (lengths, times), never the recognized text or the prompt. - -Pvoice.abis=arm64-v8a builds only that ABI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The debug build type sets ndk abiFilters too, which conflicts with ABI splits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured with large-v3-turbo (not trained for a shorter window): one sentence of 3 s came out twice. If a run of at least 3 words directly repeats itself, the audio is transcribed again with the full 30 s window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The arm64 build was compiled for ARMv8.2 (dot product, FP16) only, so newer CPUs could not use i8mm, SVE or SME. ggml's CPU backend is now built in variants (GGML_BACKEND_DL, GGML_CPU_ALL_VARIANTS, KleidiAI on arm64) and the best one for the phone is loaded at runtime from the library folder (JNI_OnLoad). The libraries are extracted for that, with the shared C++ runtime. The thread pool patch looks up the CPU backend's functions instead of linking them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-plus
Normal Whisper Small with the shortened window wrote the first two sentences of a 12 s dictation
twice, with small differences ("Bruder" / "Bode"), which the direct-repeat check missed. Then the
audio is recognized again with the full window.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r window - One thread pool per thread count, never freed: the CPU backend pauses the pool it used before when it gets another one, so freeing it was a use after free - No CPU backend loaded: init fails cleanly instead of crashing the process - No shorter window when it would be the full 1500 frames anyway, nor for languages written without spaces (the repetition check can't see repeats there) - If the second run with the full window fails, the first result is kept - Release: no compat APK any more (the CPU variants cover every ARMv8 CPU), release notes for v1.1.0, README updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ggml pins the thread that creates a thread pool to that pool's cores. The cores for the next pool were read from that same thread, so after 4 threads a pool for 6 got only the 4 fast cores: 6 threads on 4 cores, which waits at every step (measured 19-45 s instead of about 1 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… JNI, text as bytes - Threads limited to the cores the process may use: more only wait for each other, and since every thread count keeps its pool, any number from a caller could otherwise create pools without end - init and transcribe catch every exception (e.g. a model file asking for more memory than there is) instead of ending the process; JNI resources are released through guards - The text comes back as UTF-8 bytes, decoded in Kotlin: NewStringUTF only takes modified UTF-8 - Debug-level engine logs are never passed on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- whisper.cpp asks an abort flag before every computation step; cancelling a session (also after the keyboard's timeout) stops its running recognition instead of letting it hold up the next dictation - Each session has its own cancel flags: a new session no longer undoes the cancel of an earlier one - The model state tells whether an import is running and how the last one ended (ok, or the reason), so the keyboard can confirm that a model is really ready Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…per process - Marking the transcribing session and aborting it happen under one lock, so a cancel that arrives just as a recognition ends can't stop the next one - Wording: whisper.cpp checks the abort flag after each encoder pass and decoding step - Import counters and the import executor live per process: a service created again during an import reports it correctly and doesn't start a second import alongside Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What changes
audio_ctx= seconds × 50 + 64, rounded up to 64). That makes the encoder several times faster. Longer recordings are unchanged.patches/, applied by CMake): without it ggml starts and ends threads for every computation step, i.e. for every decoded token. The threads are pinned to the fastest cores (bycpuinfo_max_freq); if those can't be read, nothing is pinned, as before. One pool per thread count, so changing the thread setting is safe; the fast cores are read from the process, not from the calling thread (ggml pins that thread to the first pool's cores, which made a later, bigger pool share them: 19–45 s instead of about 1 s in a test). If no CPU backend can be loaded, the model fails to load with an error instead of crashing.-PcompatCpu=truestill works but has no effect;CpuSupportstays, it just never refuses now). README and release notes (docs/release_notes/v1.1.0.md) are updated. The arm64-only APK with all variants is 4.4 MB. Note: ggml's CMake downloads the KleidiAI kernels during the build (fine on GitHub Actions; an offline build would needGGML_CPU_KLEIDIAI=OFF).NewStringUTFonly takes modified UTF-8. Debug-level engine logs are not passed on.-Pvoice.abis=arm64-v8abuilds one APK with only these ABIs (whisper.cpp takes long to build), libraries for 16 KB memory pages, version 1.1.0 (110).The interface to the keyboard is unchanged, so the current LeanType works with it as before. The keyboard PR in LeanBitLab/LeanType (it links here) adds an optional speed display and the name of the imported model.
How we tested
Phone: Dimensity 9400+ (1× Cortex-X925, 3× Cortex-X4, 4× Cortex-A720), German. Two test dictations: one sentence (about 3–4 s) and three sentences (about 11–12 s). Measured with the speed display of the keyboard PR: time from the last spoken word until the text is there.
It started with a measurement of the current plugin: a single sentence took 7.7 s, three sentences hardly more (8.9 s). A fixed base, because the full 30 s window is computed every time. Turbo took 32 s. While measuring we also noticed that the app didn't show which model was active (imported models all have the same name in the plugin), so the keyboard PR shows it now.
Threads (FUTO-244, this PR, long text): 4 threads 2.7 s, 6 threads 4.5 s, 8 threads 8.2 s recognition after the recording (short sentence: about 1 s with 4 or 6). With the persistent pool every step waits for the slowest core, so the fast cores win, most clearly for longer texts where decoding dominates; with the old per-step threads 8 used to be faster than 6. 4 stays the default.
Repetition guard checked against the real outputs: the doubled text from the Small test is caught, the clean texts are not.
Recognition quality didn't change; the remaining mistakes ("Weise" instead of "Vase") are the known weakness of Small-sized models. Tested on arm64 only; armeabi-v7a and x86_64 build, but I couldn't try them on a device.
It was a lot of testing: many builds, measurement series with three models and two dead ends (Turbo repeating itself, the narrow repetition check). But I think the effort was worth it: a short sentence is there in 1.5–2 s instead of 7.7 s.
Added on 30.11.
abort_callback). Before, it ran to the end and every following dictation waited behind it. With a large model this showed up as "Voice processing timed out" for the next dictations as well. Each session also has its own cancel flags now: a new session no longer resets the cancel of the previous one, and a cancel arriving just as a recognition ends can't stop the next one.[imports=N; importing | last=ok | last=failed: reason], so the keyboard can tell whether an imported model is really ready (keyboard PR Voice input: optional speed display, name of the imported model, thread labels as measured LeanType#1002). The counters live per process, so a service created again during an import still reports it. The interface is unchanged.All work and measurements were done with Claude Code; I tested every version on the phone.
🤖 Generated with Claude Code