Skip to content

Remove unnecessary SHERPA_ONNX_API from C/C++ APIs. - #3295

Merged
csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:fix-c-api
Mar 12, 2026
Merged

csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:fix-c-api

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Mar 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Refactored API structure declarations for improved maintainability across C and C++ interfaces.
    • Enhanced FunASR Nano configuration with additional tuning parameters including tokenizer, language, and prompt settings.
    • Extended recognition results to include language identification, emotion analysis, event tracking, and timing information.

@csukuangfj
csukuangfj requested a review from Copilot March 12, 2026 03:55
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 12, 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 refining the C and C++ API headers by eliminating the SHERPA_ONNX_API macro from typedef struct and struct declarations. This change streamlines the header files, removing a redundant construct that did not contribute to the intended DLL export/import mechanism for these specific declarations, thereby enhancing the overall clarity and correctness of the API definitions.

Highlights

  • API Cleanup: Removed the SHERPA_ONNX_API macro from typedef struct and struct declarations in both C and C++ API headers. This macro is generally applied to functions or class definitions for DLL export/import, and its presence on typedef struct or struct declarations is often redundant or semantically incorrect, as the typedef itself or the functions operating on the struct would typically carry the export/import attribute.
  • Improved Code Clarity: The removal of the unnecessary macro simplifies the API definitions, making the code cleaner and easier to read without altering the functionality or external linkage behavior of the types.
Changelog
  • sherpa-onnx/c-api/c-api.h
    • Removed SHERPA_ONNX_API from typedef struct declarations for various configuration and result types (e.g., SherpaOnnxOnlineTransducerModelConfig, SherpaOnnxOfflineRecognizerResult, SherpaOnnxOfflineTtsConfig).
    • Removed SHERPA_ONNX_API from typedef struct declarations for core API types (e.g., SherpaOnnxOnlineRecognizer, SherpaOnnxOfflineTts).
  • sherpa-onnx/c-api/cxx-api.h
    • Removed SHERPA_ONNX_API from struct declarations for various offline model configuration types (e.g., OfflineTransducerModelConfig, OfflineWhisperModelConfig, OfflineModelConfig).
Activity
  • No human activity has been recorded on this pull request yet.
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 Mar 12, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 86311220-b18c-4987-a747-7744fe3a6da6

📥 Commits

Reviewing files that changed from the base of the PR and between abaf286 and 36a8d9c.

📒 Files selected for processing (2)
  • sherpa-onnx/c-api/c-api.h
  • sherpa-onnx/c-api/cxx-api.h

📝 Walkthrough

Walkthrough

This PR removes the SHERPA_ONNX_API export macro from struct typedef declarations across C and C++ API headers, affecting symbol visibility for numerous model configuration and result types. Additionally, new fields are added to OfflineFunASRNanoModelConfig and OfflineRecognizerResult in the C++ header.

Changes

Cohort / File(s) Summary
C API Header - Export Macro Removal
sherpa-onnx/c-api/c-api.h
Removed SHERPA_ONNX_API macro from ~90+ struct typedef declarations across online/offline ASR, TTS, VAD, speaker embedding, language identification, punctuation, audio tagging, speaker diarization, and speech denoising configuration and result types.
C++ API Header - Export Macro & Field Additions
sherpa-onnx/c-api/cxx-api.h
Removed SHERPA_ONNX_API macro from offline model config struct declarations. Extended OfflineFunASRNanoModelConfig with new fields (tokenizer, system_prompt, user_prompt, max_new_tokens, temperature, top_p, seed, language, itn, hotwords). Extended OfflineRecognizerResult with new fields (json, lang, emotion, event, durations).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size:XL, api-change

Poem

🐰 A rabbit hops through headers bright,
Removing macros left and right,
Structs stand tall without their veil,
New fields bloom—the API tale!
thump thump ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing SHERPA_ONNX_API export macros from C and C++ API struct declarations across both c-api.h and cxx-api.h files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • 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

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

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 removes the SHERPA_ONNX_API export/import macro from a set of public C and C++ type declarations, keeping the macro usage focused on exported functions/classes rather than plain configuration/result structs.

Changes:

  • Removed SHERPA_ONNX_API from multiple C typedef struct declarations in the public C header.
  • Removed SHERPA_ONNX_API from several C++ struct declarations in the C++ API header.

Reviewed changes

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

File Description
sherpa-onnx/c-api/cxx-api.h Drops SHERPA_ONNX_API from non-streaming C++ config/result structs.
sherpa-onnx/c-api/c-api.h Drops SHERPA_ONNX_API from C typedef struct declarations and opaque forward typedefs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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 removes the SHERPA_ONNX_API export macro from numerous C and C++ struct definitions across the public API headers (sherpa-onnx/c-api/c-api.h and sherpa-onnx/c-api/cxx-api.h). This change correctly targets data-only configuration and result structs, which do not need to be exported from a shared library, making the API surface cleaner. The API classes and functions that require exporting are unaffected. The changes are consistent and correct. No issues were found during this review.

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.

2 participants