Skip to content

AI - TTS#259

Open
gmathi wants to merge 10 commits intomainfrom
claude/merge-main-resolve-conflicts-IBiqV
Open

AI - TTS#259
gmathi wants to merge 10 commits intomainfrom
claude/merge-main-resolve-conflicts-IBiqV

Conversation

@gmathi
Copy link
Copy Markdown
Owner

@gmathi gmathi commented Mar 29, 2026

No description provided.

gmathi and others added 7 commits February 27, 2026 22:27
- Add sherpa-onnx JNI libraries for all architectures (arm64-v8a, armeabi-v7a, x86, x86_64)
- Add VITS-Piper TTS models: kusal-medium and lessac-medium
- Include espeak-ng-data for phoneme processing
Resolves conflict in TTSWrapper.kt: kept main's refactored createTrack()
helper method over HEAD's inline version, which had a null-pointer bug
(called track!! after track?.release() without reassigning track).

https://claude.ai/code/session_01NxcyS3BWxggkFHcJvwNxmR
- Tts.kt: remove unreliable finalize() override; have release() call
  free() directly to ensure prompt native memory reclamation

- TTSService.kt: remove duplicate startForeground() call in hookSystem();
  guard onTrimMemory() with isInitialized check to prevent NPE if the
  callback fires before onCreate() completes

- TTSWrapper.kt: track the BufferWriter thread and join it (200 ms max)
  in shutdown() before releasing the AudioTrack, preventing a use-after-
  free race; add null check for MediaPlayer.create() in addEarcon() to
  avoid a crash when the resource cannot be loaded

- AiTtsPreloader.kt: replace @volatile fields used in non-atomic
  compound check-then-act operations with a single stateLock; all
  mutations of preloadedPlayer/preloadedModelId/isPreloading are now
  performed inside synchronized(stateLock) blocks

- TTSPlayer.kt: guard every withUIContext callback in the AI engine init
  coroutine with isDisposed checks to prevent post-destroy context access

https://claude.ai/code/session_01NxcyS3BWxggkFHcJvwNxmR
- TTSPlayer: add aiEngineInitializing flag to prevent concurrent AI engine
  init coroutines from each calling continueStart() on completion (#25);
  track aiSpeakThread as a daemon thread so synthesis never blocks JVM
  shutdown, and interrupt it in stop()/destroy() (#3)

- TTSSettingsActivity: hide the AI voice preset setting — all bundled
  VITS-Piper models are single-speaker (sid=0) so the selector had no
  audible effect; remove now-unused AiVoicePreset import (#22)

- AiAudioPlayer: clamp PCM samples to [-1,1] before int conversion and
  use explicit bit masking to match the correct AiTtsTestViewModel
  implementation and avoid audio corruption on out-of-range samples (#11)

- NovelLibraryApplication: call AiTtsPreloader.shutdown() in
  onTerminate() to cancel the coroutine scope and release the cached
  player on graceful app termination (#5)

- TextToSpeechControlsActivity: remove unused
  androidx.compose.runtime.remember import (#28)

https://claude.ai/code/session_01NxcyS3BWxggkFHcJvwNxmR
@gmathi gmathi changed the title Add .kiro directory to .gitignore AI - TTS Mar 30, 2026
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