Skip to content

Fix warnings in Go API - #3414

Merged
csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:go
Mar 26, 2026
Merged

csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:go

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Mar 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Improved internal code organization by consolidating text generation implementation into a unified configuration-based system. No changes to public APIs or user-facing functionality.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 26, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, 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 focuses on improving the maintainability and structure of the Go API for offline Text-to-Speech (TTS) generation. By consolidating the core logic for different generation methods into a single, configurable function, it streamlines the codebase and prepares it for easier future enhancements.

Highlights

  • Refactoring: Refactored GenerateWithZipvoice and GenerateWithCallback functions to utilize a new common GenerateWithConfig method, reducing code duplication and centralizing generation logic.
  • Improved API Usage: Introduced a GenerationConfig struct to encapsulate parameters for TTS generation, making function calls cleaner and more extensible.
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.

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 Mar 26, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a5fa30e5-67cd-41bc-82a7-da0b3592529c

📥 Commits

Reviewing files that changed from the base of the PR and between b3a0463 and 7b9dfe8.

📒 Files selected for processing (1)
  • scripts/go/sherpa_onnx.go

📝 Walkthrough

Walkthrough

Two TTS generation methods in the Go bindings are refactored to delegate to a shared GenerateWithConfig implementation. GenerateWithZipvoice and GenerateWithCallback now construct configuration objects containing relevant parameters and route execution through the unified configuration-based path, reducing code duplication.

Changes

Cohort / File(s) Summary
TTS Generation Refactoring
scripts/go/sherpa_onnx.go
GenerateWithZipvoice and GenerateWithCallback methods consolidated to build GenerationConfig objects and delegate to GenerateWithConfig instead of calling Zipvoice-specific and callback-specific C APIs directly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • #3151 — Modifies the same Go TTS methods GenerateWithCallback and GenerateWithZipvoice in the codebase.
  • #3364 — Refactors TTS generation calls to use the GenerationConfig-based GenerateWithConfig API with updated callback wiring.
  • #2628 — Modifies OfflineTts.GenerateWithZipvoice and adds the underlying C API binding that this PR's refactoring now delegates to.

Suggested labels

size:XS

Poem

🐇 A rabbit's refactor rhyme:
Two paths now flow as one divine stream,
Config objects hold each gleaming dream,
Zipvoice and callbacks, both set free,
To delegate and dance in harmony! 🎵

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 merged commit 2da3796 into k2-fsa:master Mar 26, 2026
1 check was pending
@csukuangfj
csukuangfj deleted the go branch March 26, 2026 02:53

@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 refactors the GenerateWithZipvoice and GenerateWithCallback methods within the OfflineTts struct. Both methods now construct a GenerationConfig struct and delegate the audio generation logic to a new, generalized GenerateWithConfig method, reducing code duplication and improving reusability. The GenerateWithCallback method also adapts its existing callback to the new progress callback mechanism. I have no feedback to provide.

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant