Skip to content

Fix matcha tts - #2856

Merged
csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:fix-matcha
Dec 4, 2025
Merged

csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:fix-matcha

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Dec 4, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Optimized internal code structure by reorganizing token processing sequence and eliminating duplicate operations to improve efficiency without affecting functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Dec 4, 2025
@csukuangfj
csukuangfj merged commit 7cfded8 into k2-fsa:master Dec 4, 2025
26 of 27 checks passed
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @csukuangfj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug in the Matcha Text-to-Speech (TTS) implementation where a critical step in token processing was inadvertently placed within a debug-only conditional block. By moving this logic to execute unconditionally, the fix ensures that the TTS system consistently receives properly prepared input, allowing it to function correctly in all operational modes.

Highlights

  • Matcha TTS Token Processing: The logic responsible for concatenating input tokens into the x vector was moved outside of the if (config_.model.debug) block. This ensures that the tokens are always correctly processed and prepared for the Matcha TTS model, regardless of whether debug mode is enabled or not.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@coderabbitai

coderabbitai Bot commented Dec 4, 2025 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

A refactoring that moves token vector construction earlier in the Process function of offline-tts-matcha-impl.h, eliminating a redundant insertion loop previously located in a debug section. No changes to control flow or output values.

Changes

Cohort / File(s) Change Summary
Token Vector Construction Refactoring
sherpa-onnx/csrc/offline-tts-matcha-impl.h
Moved token aggregation loop earlier in Process function and removed duplicate token concatenation logic from debug section.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify the relocated loop maintains identical behavior before and after the move
  • Confirm debug output remains functionally equivalent after removing the redundant section

Possibly related PRs

Suggested labels

size:M

Poem

🐰 A loop moved up the stack with care,
Redundant work? We'll not keep there!
Same output, cleaner flow,
Debug logs still steal the show. ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 5e7e252 and 2d4ced9.

📒 Files selected for processing (1)
  • sherpa-onnx/csrc/offline-tts-matcha-impl.h (1 hunks)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@csukuangfj
csukuangfj deleted the fix-matcha branch December 4, 2025 05:50

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request correctly fixes a bug in OfflineTtsMatchaImpl::Process where the input tensor x was only being populated in debug mode. By moving the population of x outside the if (config_.model.debug) block, the function now behaves correctly in all build configurations. The change is clear and addresses the issue effectively. I have no further comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant