Skip to content

feat(voice-integration): Add whispercpp voice integration and model management - #756

Merged
haiphucnguyen merged 6 commits into
mainfrom
feature/improvements
Oct 9, 2026
Merged

haiphucnguyen merged 6 commits into
mainfrom
feature/improvements

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Summary

  • Support local whispercpp
  • Updated VoiceServiceRegistry to include WhisperCppFfmSpeechToTextFactory
  • Modified AppConfig and AskimoHome to manage whisper model paths
  • Enhanced VoiceSettingsSection with UI for whisper model selection and download

Related Issue(s)

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactor (no functional change)
  • 🧪 Tests
  • 🔧 Chore / tooling / CI

What Changed & Why

Support local whispercpp

How to Test

./gradlew test

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING guide
  • My branch is up to date with main
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

Additional Notes

…anagement

- Added native headers and script for whispercpp integration
- Updated VoiceServiceRegistry to include WhisperCppFfmSpeechToTextFactory
- Modified AppConfig and AskimoHome to manage whisper model paths
- Enhanced VoiceSettingsSection with UI for whisper model selection and download
- Updated various components to support the new whispercpp provider and model checks
Copilot AI balanced review requested due to automatic review settings October 9, 2026 17:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Windows ABI incompatibility, leaked native model contexts, and invalid model fallbacks currently prevent reliable use.

8 open findings
What changed in this PR

Adds local in-process whisper.cpp transcription with model management and platform-native FFM integration.

Changes:

  • Adds local Whisper model download, selection, configuration, and localization.
  • Adds FFM bindings, native loading, and speech-to-text registration.
  • Supports independently disabling STT or TTS.
File Description
shared-jvm/​.../​AskimoHome.kt Adds model storage paths.
shared-jvm/​.../​AppConfig.kt Adds providers and model-path configuration.
desktop/​.../​VoiceSettingsSection.kt Adds provider and model-management UI.
natives/​whisper/​windows-x86_64/​.manifest Lists Windows x64 natives.
natives/​whisper/​windows-aarch64/​.manifest Lists Windows ARM64 natives.
natives/​whisper/​macos/​.manifest Lists macOS natives.
natives/​whisper/​linux-x86_64/​.manifest Lists Linux x64 natives.
natives/​whisper/​linux-aarch64/​.manifest Lists Linux ARM64 natives.
i18n/​messages.properties Adds English voice strings.
i18n/​messages_zh_TW.properties Adds Traditional Chinese strings.
i18n/​messages_zh_CN.properties Adds Simplified Chinese strings.
i18n/​messages_vi_VN.properties Adds Vietnamese strings.
i18n/​messages_pt_BR.properties Adds Portuguese strings.
i18n/​messages_ko_KR.properties Adds Korean strings.
i18n/​messages_ja_JP.properties Adds Japanese strings.
i18n/​messages_fr.properties Adds French strings.
i18n/​messages_es.properties Adds Spanish strings.
i18n/​messages_de.properties Adds German strings.
VoiceServiceRegistry.kt Registers the FFM STT factory.
SpeechToTextService.kt Updates STT documentation.
WhisperModelDownloader.kt Implements model downloading and deletion.
WhisperModelCatalog.kt Defines downloadable model tiers.
WhisperCppFfmSpeechToTextService.kt Implements native transcription.
NativeLibraryLoader.kt Extracts and loads platform natives.
OpenAiSpeechToTextService.kt Changes the fallback model.
LocalWhisperSpeechToTextService.kt Updates local Whisper integration text.
ChatMessageList.kt Honors disabled TTS.
ChatInputField.kt Honors disabled STT.
AgentRunArea.kt Honors disabled STT for agents.
whisper_vad_params.java Adds generated VAD bindings.
whisper_h$shared.java Adds shared FFM layouts.
whisper_h.java Adds generated Whisper calls.
whisper_context_params.java Adds context-parameter bindings.
whisper_aheads.java Adds alignment-head bindings.
generate-whisper-bindings.sh Adds binding generation tooling.
whisper.h Vendors the Whisper API header.
parakeet.h Vendors the Parakeet header.
gguf.h Vendors GGUF definitions.
ggml-metal.h Vendors Metal backend definitions.
ggml-cpu.h Vendors CPU backend definitions.
ggml-blas.h Vendors BLAS backend definitions.
ggml-backend.h Vendors backend API definitions.
ggml-alloc.h Vendors allocator definitions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Windows bindings are ABI-incompatible, and native-context cleanup can race active inference.

1 open finding
8 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Close response bodies before throwing on HTTP errors

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperModelDownloader.kt:83

The ofInputStream() body is left open on non-2xx responses. Repeated failed attempts can retain HTTP connections/resources until GC; close the body before throwing.

This issue also appears in the following locations of the same file:

  • line 103
  • line 108
Medium severity Handle download cancellation separately from UI errors

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​settings/​VoiceSettingsSection.kt:935

This handler also catches CancellationException, so cancellation of the composable scope is converted into a UI error/state update instead of propagating. Handle cancellation separately before ordinary download failures.

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Windows bindings have an incompatible ABI, and model download and native lifecycle paths contain reliability issues.

1 open finding
1 resolved since last review
Previously missed (4)

In code that hasn't changed since last review

Medium severity Validate native binaries beyond file size

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​NativeLibraryLoader.kt:143

File size does not identify a native binary. After an app update, a replacement library with the same byte count is skipped, so the persistent profile cache can load an old ABI against the new bindings. Use a versioned extraction directory or verify a bundled digest rather than size alone.

Medium severity Close failed HTTP response bodies

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperModelDownloader.kt:84

The response body is an open InputStream, but the non-2xx path throws without closing it. Repeated failed downloads can retain HTTP connections and file descriptors until GC; close the body before reporting the status failure.

Medium severity Preserve coroutine cancellation during download errors

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperModelDownloader.kt:106

The catch wraps CancellationException raised by ensureActive() as a service failure, breaking coroutine cancellation semantics. Delete the partial file and rethrow cancellation unchanged before handling ordinary download errors.

Medium severity Fallback when atomic model moves are unsupported

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperModelDownloader.kt:108

ATOMIC_MOVE is optional and throws AtomicMoveNotSupportedException on valid filesystems. In that case a fully downloaded model is reported as failed and never reaches its final path. Fall back to a regular replace move, as PropertyFilePreferences.kt:52-60 already does.

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Windows FFM ABI mismatch and native lifecycle defects can break transcription or leak resources.

6 open findings
1 resolved since last review

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The Windows FFM bindings are incompatible, and first-run configuration still selects OpenAI instead of the intended local provider.

0 open findings

1 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Close failed download response bodies before throwing

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperModelDownloader.kt:112

A non-2xx response already owns an open InputStream body, but this branch throws without closing it. Repeated failed/retried model downloads can leak HTTP connections and descriptors; close the body before raising the service exception.

Medium severity Update generated defaults to select the local Whisper provider

shared-jvm/​src/​main/​kotlin/​io/​askimo/​core/​config/​AppConfig.kt:537

The effective first-run default is still OPENAI: AppConfig.DEFAULT_YAML writes voice.stt_provider: OPENAI (AppConfig.kt:923-926), and new profiles are deserialized from that file. Consequently this constructor-default change never selects the new local provider in a normal installation, despite the new availability/UI logic treating it as the default. Update the generated default YAML to LOCAL_WHISPER_FFM as part of this change.

🧠 Review effort: Balanced

@haiphucnguyen
haiphucnguyen merged commit 68ce8c2 into main Oct 9, 2026
10 of 11 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/improvements branch October 9, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants