Skip to content

refactor(voice): Refactor voice service implementations and enhance UI volume visualization - #693

Merged
haiphucnguyen merged 1 commit into
mainfrom
feature/improve-voice-recording
Sep 3, 2026
Merged

haiphucnguyen merged 1 commit into
mainfrom
feature/improve-voice-recording

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator
  • Specialized service implementations (Local Whisper, Piper, OpenAI) are introduced for decoupled voice functionality.
  • Refactor TTS and STT services into dedicated, specialized classes.
  • Apply perceptual volume boosting to voice waveform samples in the UI for better visual fidelity.

…I volume visualization

- Specialized service implementations (Local Whisper, Piper, OpenAI) are introduced for decoupled voice functionality.
- Refactor TTS and STT services into dedicated, specialized classes.
- Apply perceptual volume boosting to voice waveform samples in the UI for better visual fidelity.
Copilot AI lite review requested due to automatic review settings September 3, 2026 23:52

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 new/updated STT implementations appear to misuse LangChain4j’s HTTP client builder API and hard-code WAV MIME type, which is likely to cause compilation/runtime issues.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR refactors the desktop voice layer by splitting OpenAI STT/TTS into dedicated service classes, updating local OpenAI-compatible (Piper/Whisper) services to use the shared JDK HTTP client configuration, and improving the live mic waveform visualization by applying a perceptual gain curve.

Changes:

  • Extract OpenAI TTS/STT implementations into OpenAiTextToSpeechService and OpenAiSpeechToTextService.
  • Update local Piper TTS and local Whisper STT to use createJdkHttpClientBuilder(...) when constructing LangChain4j OpenAI-compatible models.
  • Boost UI waveform sample levels using a sqrt curve + gain for more visible speech activity.
File summaries
File Description
desktop-shared/src/main/kotlin/io/askimo/ui/voice/impl/PiperTextToSpeechService.kt Removes embedded OpenAI TTS implementation and configures Piper model with shared JDK HTTP client builder.
desktop-shared/src/main/kotlin/io/askimo/ui/voice/impl/OpenAiTextToSpeechService.kt New OpenAI TTS service + factory, wired through shared JDK HTTP client builder.
desktop-shared/src/main/kotlin/io/askimo/ui/voice/impl/OpenAiSpeechToTextService.kt New OpenAI STT service + factory; currently has builder wiring and MIME-type handling issues.
desktop-shared/src/main/kotlin/io/askimo/ui/voice/impl/LocalWhisperSpeechToTextService.kt Updates local Whisper STT to use shared JDK HTTP client builder; currently uses a likely-wrong builder API.
desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatInputField.kt Improves waveform visualization by applying perceptual boosting to RMS levels before rendering.
Review details

Suppressed comments (1)

desktop-shared/src/main/kotlin/io/askimo/ui/voice/impl/LocalWhisperSpeechToTextService.kt:41

  • createJdkHttpClientBuilder(baseUrl) returns a JdkHttpClientBuilder, but it’s being passed to OpenAiAudioTranscriptionModel.builder().httpClientProvider(...). This is inconsistent with other model builders in the codebase and is likely a type/compilation error; use httpClientBuilder(...) so proxy/timeout settings are applied correctly.
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

Comment on lines +38 to +40
val model = OpenAiAudioTranscriptionModel.builder()
.httpClientProvider(createJdkHttpClientBuilder())
.apiKey(apiKey)
.modelName(config.sttModel.ifBlank { "whisper-1" })
.build()

model.transcribeToText(Audio.builder().base64Data(Base64.getEncoder().encodeToString(audio)).mimeType("audio/wav").build())
@haiphucnguyen
haiphucnguyen merged commit 0f0c582 into main Sep 3, 2026
10 of 11 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/improve-voice-recording branch September 3, 2026 23:59
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