feat(tts): add Kokoro-82M TTS model implementation (#127)#165
Merged
Conversation
Add text-to-speech module with Kokoro-82M StyleTTS2-based model: - KokoroConfig: Model configuration dataclass with PLBERT/ISTFTNet params - KokoroTokenizer: G2P conversion with misaki integration - Neural network layers: Conv1d, BERT, StyleEncoder, Decoder, ISTFTNet - Model loader: SafeTensors/PTH weight loading with HuggingFace Hub support - KokoroModel: High-level API for text-to-speech synthesis - Audio utilities: WAV export/import, resampling, concatenation Architecture: PLBERT (12L, 768H) -> StyleEncoder (128D) -> Decoder (3L, 512H) -> ISTFTNet (60x upsample) Output: 24kHz audio Note: Forward pass is placeholder (sine wave output). Full inference requires matching actual Kokoro weight structure from HuggingFace hexgrad/Kokoro-82M. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Implement LSTM forward kernel with kernel-based memory copies (Driver API compatible, no cudaMemcpy) - Add bidirectional LSTM support with concatenation kernel - Add Python API: lstm_forward(), lstm_bidirectional() - Update TTS layers to use native LSTM kernel - Add examples/tts.py with LSTM tests and benchmarks Performance (RTX 5090, batch=8, seq=100, hidden=512): - 39.96 ms/forward, ~20k tokens/sec Closes #127 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f482514 to
53bb16c
Compare
- Fix misaki G2P to properly iterate over generator of (grapheme, phoneme) tuples - Handle Unicode IPA characters in console output (Windows cp932) - Remove TODO placeholder, enable full TTS synthesis in examples/tts.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.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.
Summary
pygpukit.ttsmodule with Kokoro-82M StyleTTS2-based TTS modelLSTM Kernel Implementation
Features
internal::get_capture_stream()for CUDA Graph compatibilityKernels Added
lstm_cell_f32_kernel- Single LSTM cell computation (gates, cell state, hidden)copy_f32_kernel- Simple DtoD copy (replaces cudaMemcpy)lstm_copy_to_output_f32_kernel- Strided copy for sequence outputlstm_concat_bidirectional_f32_kernel- Concatenation for bidirectional outputPython API
Performance
RTX 5090, batch=8, seq_len=100, input=768, hidden=512:
TTS Architecture
Files Added/Modified
native/ops/nn/recurrent/lstm_kernels.cuh- LSTM CUDA kernelsnative/ops/nn/recurrent/lstm.inl- LSTM dispatchnative/bindings/nn/recurrent.cpp- Python bindingssrc/pygpukit/ops/nn.py-lstm_forward,lstm_bidirectionalsrc/pygpukit/tts/kokoro/- Kokoro model implementationexamples/tts.py- LSTM tests and benchmarksTest plan
Closes #127
🤖 Generated with Claude Code