Skip to content

Add JavaScript API (node-addon) for KittenTTS - #2470

Merged
csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:javascript-node-addon
Aug 8, 2025
Merged

csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:javascript-node-addon

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Aug 8, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added support for the KittenTTS English offline text-to-speech model, including configuration options and integration in both HarmonyOS and Node.js environments.
    • Introduced a new example script demonstrating usage of the KittenTTS model for TTS synthesis.
  • Documentation
    • Updated documentation with instructions and examples for using the KittenTTS model.
  • Chores
    • Improved test scripts and workflows, including model download automation and workflow matrix cleanup.

@csukuangfj
csukuangfj requested a review from Copilot August 8, 2025 08:21

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.

Pull Request Overview

This PR adds JavaScript API support for KittenTTS, a text-to-speech model. It introduces configuration and implementation for the Kitten TTS model across the Node.js addon and Harmony OS platforms.

  • Adds Node.js example demonstrating KittenTTS usage with configuration and audio generation
  • Implements KittenTTS model configuration support in both Node.js addon and Harmony OS
  • Updates CI workflow to test the new KittenTTS functionality

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
nodejs-addon-examples/test_tts_non_streaming_kitten_en.js New example demonstrating KittenTTS usage with audio generation
nodejs-addon-examples/README.md Adds documentation for the new KittenTTS example
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/ets/components/NonStreamingTts.ets Adds KittenTTS model configuration class
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc Implements C++ configuration parsing for KittenTTS
harmony-os/SherpaOnnxHar/sherpa_onnx/Index.ets Exports the new KittenTTS configuration class
.github/workflows/test-nodejs-addon-api.yaml Updates CI configuration for testing
.github/scripts/test-nodejs-addon-npm.sh Adds KittenTTS testing to CI script
Comments suppressed due to low confidence (1)

@@ -37,9 +37,9 @@ jobs:
strategy:
fail-fast: false

Copilot AI Aug 8, 2025

Copy link

Choose a reason for hiding this comment

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

The matrix was changed to remove a duplicate 'ubuntu-latest' entry, but this appears to reduce test coverage. Consider adding a comment explaining why this OS configuration was changed or verify this is intentional.

Suggested change
fail-fast: false
fail-fast: false
# The matrix previously included a duplicate 'ubuntu-latest' entry.
# It was removed to avoid redundancy and does not reduce test coverage,
# as all required configurations are still tested.

Copilot uses AI. Check for mistakes.
matrix:
os: [macos-latest, ubuntu-latest, ubuntu-latest]
os: [macos-latest, ubuntu-latest]
node-version: ["16", "22"]

Copilot AI Aug 8, 2025

Copy link

Choose a reason for hiding this comment

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

The Python version was updated from '3.8' to '3.10'. Consider adding a comment or documentation explaining the reason for this version requirement change.

Suggested change
node-version: ["16", "22"]
node-version: ["16", "22"]
# Updated Python version from 3.8 to 3.10 to support dependencies and features required by the project.

Copilot uses AI. Check for mistakes.
@coderabbitai

coderabbitai Bot commented Aug 8, 2025 •

Copy link
Copy Markdown

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Caution

Review failed

The pull request is closed.

Walkthrough

Support for the "kitten" offline text-to-speech (TTS) model was added across multiple layers: C++ backend, Harmony OS ETS classes, Node.js test scripts, and documentation. The Node.js addon test workflow was updated to include the new model, and the GitHub Actions workflow matrix was simplified and updated for Python version.

Changes

Cohort / File(s) Change Summary
Node.js Kitten TTS Example & Integration
nodejs-addon-examples/test_tts_non_streaming_kitten_en.js, nodejs-addon-examples/README.md, .github/scripts/test-nodejs-addon-npm.sh
Introduced a Node.js example script for Kitten TTS, updated documentation with usage and download instructions, and modified the test script to download, extract, and clean up the Kitten TTS model before running the new test.
Harmony OS TTS Model Config Support
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/ets/components/NonStreamingTts.ets, harmony-os/SherpaOnnxHar/sherpa_onnx/Index.ets
Added OfflineTtsKittenModelConfig class and integrated it into the main TTS model config; updated exports to include the new config.
C++ TTS Model Parsing and Cleanup
harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc
Added parsing logic for the Kitten TTS model config, updated TTS config struct assignment, and enhanced cleanup in the TTS wrapper for Kitten model string fields.
CI Workflow Matrix Update
.github/workflows/test-nodejs-addon-api.yaml
Removed duplicate OS entry and updated Python version in the GitHub Actions matrix for Node.js addon API tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NodeScript as Node.js Test Script
    participant TTSAddon as Node.js Addon (C++)
    participant ModelFiles
    participant OutputWav

    User->>NodeScript: Run test_tts_non_streaming_kitten_en.js
    NodeScript->>ModelFiles: Load Kitten model files
    NodeScript->>TTSAddon: Create OfflineTts instance with Kitten config
    NodeScript->>TTSAddon: Synthesize speech from text
    TTSAddon-->>NodeScript: Return waveform data
    NodeScript->>OutputWav: Write waveform to WAV file
    NodeScript->>User: Log timings and output filename
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Poem

A "kitten" voice now softly purrs,
Through scripts and configs, code occurs.
From Node to C++ it flows,
With docs and tests, the support grows.
A model fetched, a WAV file spun—
The TTS journey has begun!
🐾


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6bfab7 and 0a51dc6.

📒 Files selected for processing (7)
  • .github/scripts/test-nodejs-addon-npm.sh (1 hunks)
  • .github/workflows/test-nodejs-addon-api.yaml (1 hunks)
  • harmony-os/SherpaOnnxHar/sherpa_onnx/Index.ets (1 hunks)
  • harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc (3 hunks)
  • harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/ets/components/NonStreamingTts.ets (1 hunks)
  • nodejs-addon-examples/README.md (2 hunks)
  • nodejs-addon-examples/test_tts_non_streaming_kitten_en.js (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@csukuangfj
csukuangfj merged commit 6a61791 into k2-fsa:master Aug 8, 2025
@csukuangfj
csukuangfj deleted the javascript-node-addon branch August 8, 2025 08:27
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