Skip to content

Use a shorter name for Zipvoice models. - #2894

Merged
csukuangfj merged 2 commits into
k2-fsa:masterfrom
csukuangfj:refactor-zipvoice-rename
Dec 11, 2025
Merged

csukuangfj merged 2 commits into
k2-fsa:masterfrom
csukuangfj:refactor-zipvoice-rename

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Dec 11, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Breaking Changes

    • Renamed TTS config fields across bindings and CLIs: textModel/text_model/TextModel → encoder; flowMatchingModel/flow_matching_model/FlowMatchingModel → decoder; PinyinDict → Lexicon. CLI flags updated to match (e.g., --zipvoice-encoder/--zipvoice-decoder/--zipvoice-lexicon).
  • Updates

    • Example/default model artifacts switched to int8-quantized variants and include an explicit vocoder file path; example prompts and sample audio updated accordingly.

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

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 11, 2025
@coderabbitai

coderabbitai Bot commented Dec 11, 2025 •

Copy link
Copy Markdown

Walkthrough

This PR systematically renames ZipVoice offline TTS model configuration fields across the codebase: textModel/text_model → encoder, flowMatchingModel/flow_matching_model → decoder, and PinyinDict/pinyin_dict → lexicon/Lexicon. Changes touch C/C++ core, language bindings, examples, and scripts to reflect the new field names.

Changes

Cohort / File(s) Summary
C/C++ API Core Definitions
sherpa-onnx/c-api/c-api.h, sherpa-onnx/c-api/cxx-api.h
Replaced struct fields text_model/flow_matching_model with encoder/decoder in public config structs.
C/C++ API Implementations
sherpa-onnx/c-api/c-api.cc, sherpa-onnx/c-api/cxx-api.cc
Updated assignments and mappings to use encoder/decoder instead of text_model/flow_matching_model.
C++ Core Config & Validation
sherpa-onnx/csrc/offline-tts-zipvoice-model-config.h, sherpa-onnx/csrc/offline-tts-zipvoice-model-config.cc, sherpa-onnx/csrc/offline-tts-model-config.cc
Renamed members, constructor params, validation checks, and ToString/serialization to use encoder/decoder.
C++ Model Implementation
sherpa-onnx/csrc/offline-tts-zipvoice-model.cc, sherpa-onnx/csrc/offline-tts-impl.cc
Switched model-loading, init params, debug labels, and ZipVoice selection logic to encoder/decoder.
Dart/Flutter Bindings
flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart, flutter/sherpa_onnx/lib/src/tts.dart
Renamed struct fields and propagated changes through ctor, toJson/fromJson, memory management, and generation paths (encoder/decoder replace textModel/flowMatchingModel).
Go Bindings & Examples
scripts/go/sherpa_onnx.go, go-api-examples/non-streaming-tts/main.go, go-api-examples/non-streaming-tts/run-zipvoice.sh
Renamed config fields and CLI flags to --zipvoice-encoder/--zipvoice-decoder and updated example model file paths (including int8 variants) and lexicon flag.
Python Bindings & Examples
sherpa-onnx/python/csrc/offline-tts-zipvoice-model-config.cc, python-api-examples/offline-zeroshot-tts.py
Updated pybind constructor arg names and exposed members (encoder/decoder) and CLI flags/usage in example.
.NET / C# Bindings
scripts/dotnet/OfflineTtsZipVoiceModelConfig.cs
Renamed public fields TextModel→Encoder, FlowMatchingModel→Decoder, PinyinDict→Lexicon and constructor initialization.
WASM / JavaScript
wasm/tts/sherpa-onnx-tts.js, wasm/tts/sherpa-onnx-wasm-main-tts.cc
Replaced textModel/flowMatchingModel with encoder/decoder in buffer layouts, serialization, and debug printing.
Pascal API
sherpa-onnx/pascal-api/sherpa_onnx.pas
Renamed record fields and constructor mappings: TextModel/FlowMatchingModel→Encoder/Decoder, PinyinDict→Lexicon.
Swift Example
swift-api-examples/SherpaOnnx.swift
Updated function signature and config construction to use encoder/decoder.
Examples & CLI Invocations
sherpa-onnx/csrc/sherpa-onnx-offline-zeroshot-tts.cc, example scripts
Updated CLI options, prompt content, and model artifact paths to reflect encoder/decoder and lexicon, and to use int8 model variants and vocoder path.
Bindings (Dart FFI)
flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart
FFI struct field renames and pointer handling updated to encoder/decoder.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to cross-language constructor argument order and defaults (C++ ↔ Python ↔ Go ↔ Dart).
  • Verify no remaining references to the old names in less obvious places (tests, docs, generated files).
  • Confirm CLI flag help text and example scripts match new field names and model file paths.

Possibly related PRs

Poem

🐰 I hopped through code with tiny paws,
Swapped text for encoder, flow for claws—er, decoder,
Lexicon tucked in my kit of tricks,
Models renamed with nimble flicks,
A celebratory thump — hop, hop, hooray! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'Use a shorter name for Zipvoice models' accurately summarizes the main change: renaming textModel/flowMatchingModel to encoder/decoder across multiple files and language bindings.
✨ 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 72d8e05 and 560bf21.

📒 Files selected for processing (1)
  • go-api-examples/non-streaming-tts/run-zipvoice.sh (1 hunks)
🔇 Additional comments (3)
go-api-examples/non-streaming-tts/run-zipvoice.sh (3)

6-10: ✅ File existence check now uses correct int8 model filename.

The check has been properly updated to verify encoder.int8.onnx instead of the legacy non-int8 filename, ensuring the script correctly detects whether the int8 model tarball has already been extracted and avoids unnecessary re-downloads.


12-14: ✅ Vocoder model download logic is clean.

The new vocoder section properly checks for local existence before downloading, consistent with the model download pattern above.


20-26: ✅ Command invocation correctly uses renamed field names.

The flags align with the PR's renaming scheme:

  • --zipvoice-encoder and --zipvoice-decoder (replacing old model naming)
  • --zipvoice-lexicon (renamed from pinyin_dict)
  • --zipvoice-data-dir (properly points to espeak-ng-data within the int8 model directory)
  • All file paths consistently reference the int8 variant and local vocoder model

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.

@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 focuses on refining the naming conventions for Zipvoice Text-to-Speech (TTS) model components within the Sherpa-Onnx library. The primary goal is to enhance code clarity and maintainability by introducing more descriptive and concise names for model parts. Specifically, the textModel and flowMatchingModel identifiers have been updated to encoder and decoder, and pinyinDict to lexicon. These changes are propagated throughout the entire project, including various language bindings and example usage, ensuring a consistent and understandable structure for developers.

Highlights

  • Standardized Zipvoice Model Naming: The textModel and flowMatchingModel fields for Zipvoice Text-to-Speech (TTS) models have been renamed to encoder and decoder, respectively. This change improves clarity and consistency across the codebase.
  • Lexicon Field Renaming: The pinyinDict field in Zipvoice model configurations has been generalized and renamed to lexicon to better reflect its purpose and allow for broader applicability beyond Pinyin dictionaries.
  • Comprehensive Updates Across Languages: All relevant example scripts (Go, Python, C++), API bindings (Flutter, Go, C#, Swift, WASM), and core C/C++ implementations have been updated to reflect these new naming conventions and ensure compatibility.
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. ↩

@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 introduces a consistent renaming of Zipvoice model parameters across the entire codebase, changing textModel to encoder and flowMatchingModel to decoder. It also standardizes PinyinDict to Lexicon in various API bindings. The changes are applied consistently across multiple languages including Dart, Go, C#, Python, C++, and Pascal. The related example scripts and documentation have also been updated to reflect these changes. The code formatting has been improved in some files as well. Overall, this is a solid refactoring that improves code clarity and consistency. I have not found any issues of medium or higher severity.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sherpa-onnx/c-api/cxx-api.cc (1)

149-160: Fix Decode loops incrementing n instead of i

Both:

  • OnlineRecognizer::Decode(const OnlineStream *ss, int32_t n) and
  • KeywordSpotter::Decode(const OnlineStream *ss, int32_t n)

use for (int32_t i = 0; i != n; ++n), which increments n instead of i, causing a non-terminating loop and repeatedly writing streams[0].

This is a correctness bug and can also lead to UB if n overflows.

Suggested fix:

@@
-  std::vector<const SherpaOnnxOnlineStream *> streams(n);
-  for (int32_t i = 0; i != n; ++n) {
-    streams[i] = ss[i].Get();
-  }
+  std::vector<const SherpaOnnxOnlineStream *> streams(n);
+  for (int32_t i = 0; i != n; ++i) {
+    streams[i] = ss[i].Get();
+  }
@@
-  std::vector<const SherpaOnnxOnlineStream *> streams(n);
-  for (int32_t i = 0; i != n; ++n) {
-    streams[i] = ss[i].Get();
-  }
+  std::vector<const SherpaOnnxOnlineStream *> streams(n);
+  for (int32_t i = 0; i != n; ++i) {
+    streams[i] = ss[i].Get();
+  }

Also applies to: 561-567

🧹 Nitpick comments (5)
scripts/dotnet/OfflineTtsZipVoiceModelConfig.cs (1)

7-46: .NET ZipVoice config fields correctly mirror C struct after rename

Encoder/Decoder/Lexicon replace the old names while preserving field order and types, so the marshaled layout stays compatible with SherpaOnnxOfflineTtsZipvoiceModelConfig. Just be aware this is a source-breaking rename for existing .NET callers and may warrant a brief note in release docs.

sherpa-onnx/csrc/offline-tts-model-config.cc (1)

40-48: ZipVoice validation gate correctly follows decoder rename

Switching the guard to !zipvoice.decoder.empty() maintains the prior behavior that “having the main ZipVoice model path set” triggers zipvoice.Validate(). If in the future both encoder and decoder become strictly required, you might want to gate on both here for symmetry with the creation logic.

sherpa-onnx/c-api/cxx-api.h (1)

429-441: C++ ZipVoice wrapper fields renamed consistently to encoder/decoder

OfflineTtsZipvoiceModelConfig now exposes encoder/decoder, matching the underlying C struct and other model configs. This is a source-level rename for C++ callers but doesn’t affect layout or interop.

sherpa-onnx/csrc/offline-tts-zipvoice-model-config.cc (1)

15-36: ZipVoice config validation and diagnostics now align with encoder/decoder

  • CLI options --zipvoice-encoder/--zipvoice-decoder are correctly registered and validated, including file-existence checks.
  • ToString() and error messages now report encoder/decoder, matching the renamed fields.

You might optionally tweak the help strings from “text model / flow-matching decoder model” to “encoder model / decoder model” for consistency, but behavior is already correct.

Also applies to: 38-67, 123-139

sherpa-onnx/csrc/offline-tts-zipvoice-model.cc (1)

35-54: ZipVoice encoder/decoder sessions are wired correctly

The ZipVoice implementation now:

  • Loads config.zipvoice.encoder and config.zipvoice.decoder,
  • Instantiates the first Ort::Session from the encoder buffer and the second from the decoder buffer, and
  • Adjusts debug output headings to ---encoder---/---decoder---.

Behavior matches the previous text/flow-matching setup; only naming changed. If desired, you could rename text_buf to encoder_buf for readability.

Also applies to: 193-273

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e4ac57 and 72d8e05.

📒 Files selected for processing (22)
  • flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart (1 hunks)
  • flutter/sherpa_onnx/lib/src/tts.dart (17 hunks)
  • go-api-examples/non-streaming-tts/main.go (1 hunks)
  • go-api-examples/non-streaming-tts/run-zipvoice.sh (1 hunks)
  • python-api-examples/offline-zeroshot-tts.py (3 hunks)
  • scripts/dotnet/OfflineTtsZipVoiceModelConfig.cs (3 hunks)
  • scripts/go/sherpa_onnx.go (2 hunks)
  • sherpa-onnx/c-api/c-api.cc (1 hunks)
  • sherpa-onnx/c-api/c-api.h (1 hunks)
  • sherpa-onnx/c-api/cxx-api.cc (1 hunks)
  • sherpa-onnx/c-api/cxx-api.h (1 hunks)
  • sherpa-onnx/csrc/offline-tts-impl.cc (2 hunks)
  • sherpa-onnx/csrc/offline-tts-model-config.cc (1 hunks)
  • sherpa-onnx/csrc/offline-tts-zipvoice-model-config.cc (3 hunks)
  • sherpa-onnx/csrc/offline-tts-zipvoice-model-config.h (2 hunks)
  • sherpa-onnx/csrc/offline-tts-zipvoice-model.cc (6 hunks)
  • sherpa-onnx/csrc/sherpa-onnx-offline-zeroshot-tts.cc (1 hunks)
  • sherpa-onnx/pascal-api/sherpa_onnx.pas (4 hunks)
  • sherpa-onnx/python/csrc/offline-tts-zipvoice-model-config.cc (1 hunks)
  • swift-api-examples/SherpaOnnx.swift (2 hunks)
  • wasm/tts/sherpa-onnx-tts.js (4 hunks)
  • wasm/tts/sherpa-onnx-wasm-main-tts.cc (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
wasm/tts/sherpa-onnx-tts.js (1)
wasm/asr/sherpa-onnx-asr.js (45)
  • encoderLen (95-95)
  • encoderLen (130-130)
  • encoderLen (643-643)
  • encoderLen (780-780)
  • encoderLen (824-824)
  • encoderLen (870-870)
  • encoderLen (918-918)
  • decoderLen (96-96)
  • decoderLen (131-131)
  • decoderLen (644-644)
  • decoderLen (781-781)
  • decoderLen (825-825)
  • decoderLen (919-919)
  • n (99-99)
  • n (133-133)
  • n (157-157)
  • n (173-173)
  • n (189-189)
  • n (647-647)
  • n (678-678)
  • n (695-695)
  • n (712-712)
  • n (729-729)
  • n (746-746)
  • n (763-763)
  • n (785-785)
  • n (829-829)
  • n (876-877)
  • n (921-921)
  • buffer (101-101)
  • buffer (134-134)
  • buffer (158-158)
  • buffer (174-174)
  • buffer (190-190)
  • buffer (285-285)
  • buffer (379-379)
  • buffer (402-402)
  • buffer (464-464)
  • buffer (649-649)
  • buffer (680-680)
  • buffer (697-697)
  • buffer (714-714)
  • buffer (731-731)
  • buffer (748-748)
  • buffer (765-765)
scripts/dotnet/OfflineTtsZipVoiceModelConfig.cs (1)
sherpa-onnx/csrc/vocoder.h (1)
  • Vocoder (17-31)
sherpa-onnx/csrc/offline-tts-zipvoice-model-config.cc (1)
sherpa-onnx/c-api/cxx-api.cc (2)
  • FileExists (808-810)
  • FileExists (808-808)
swift-api-examples/SherpaOnnx.swift (2)
sherpa-onnx/kotlin-api/OfflineRecognizer.kt (4)
  • encoder (17-21)
  • encoder (48-54)
  • encoder (56-62)
  • encoder (64-67)
sherpa-onnx/kotlin-api/OnlineRecognizer.kt (2)
  • encoder (17-21)
  • encoder (23-26)
go-api-examples/non-streaming-tts/main.go (2)
sherpa-onnx/csrc/lexicon.cc (4)
  • Lexicon (105-122)
  • Lexicon (125-145)
  • Lexicon (402-405)
  • Lexicon (409-412)
sherpa-onnx/csrc/lexicon.h (1)
  • Lexicon (20-62)
🔇 Additional comments (21)
go-api-examples/non-streaming-tts/run-zipvoice.sh (1)

20-25: Command invocation correctly applies the model field renames.

The updates to flag names (--zipvoice-encoder, --zipvoice-decoder, --zipvoice-lexicon) and file paths (encoder.int8.onnx, decoder.int8.onnx, lexicon.txt) are consistent with the renaming scheme outlined in the PR objectives.

sherpa-onnx/c-api/c-api.h (1)

1069-1080: Zipvoice C struct rename keeps ABI while aligning with encoder/decoder naming

Renaming text_model/flow_matching_model to encoder/decoder here preserves field order and types, so the struct layout and existing sizeof/asserts remain valid while matching the rest of the API’s encoder/decoder terminology.

flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart (1)

217-235: Dart FFI ZipVoice struct stays layout-compatible with C API

Switching to encoder/decoder keeps the Pointer/Utf8 field order identical to the C struct (tokens, encoder, decoder, vocoder, data_dir, lexicon, …), so FFI layout remains correct while matching the new naming.

wasm/tts/sherpa-onnx-wasm-main-tts.cc (1)

76-86: WASM ZipVoice debug output now matches encoder/decoder naming

Printing zipvoice->encoder and zipvoice->decoder aligns the debug output with the renamed struct fields, with no impact on the surrounding size checks or logic.

sherpa-onnx/csrc/offline-tts-impl.cc (1)

39-52: ZipVoice selection now correctly keyed on encoder+decoder in both factory overloads

Both OfflineTtsImpl::Create overloads now choose OfflineTtsZipvoiceImpl only when zipvoice.encoder and zipvoice.decoder are non-empty, preserving the previous “both paths required” behavior under the new names and keeping the model-choice ordering intact.

Also applies to: 59-73

swift-api-examples/SherpaOnnx.swift (1)

930-953: Swift ZipVoice helper cleanly updated to encoder/decoder

The Swift factory now accepts encoder/decoder and forwards them in the correct order to SherpaOnnxOfflineTtsZipvoiceModelConfig, staying consistent with the C struct layout and other encoder/decoder-based configs.

sherpa-onnx/c-api/c-api.cc (1)

1243-1263: ZipVoice encoder/decoder wiring in C API is consistent

tts_config.model.zipvoice.encoder/decoder now map directly from config->model.zipvoice.encoder/decoder, aligned with the new struct fields; tokens/vocoder/data_dir/lexicon and numeric params are untouched and remain correctly forwarded.

wasm/tts/sherpa-onnx-tts.js (1)

265-327: ZipVoice WASM struct packing matches new encoder/decoder layout

The ZipVoice JS binding now correctly:

  • Computes buffer size as tokens + encoder + decoder + vocoder + dataDir + lexicon,
  • Writes strings in that order, and
  • Stores 6 pointers followed by 4 floats (featScale, tShift, targetRMS, guidanceScale) into a 10×4-byte struct,

which matches the updated C SherpaOnnxOfflineTtsZipVoiceModelConfig layout. The default offlineTtsZipVoiceModelConfig also exposes encoder/decoder keys, so external configs can set the new names directly.

Also applies to: 375-387

sherpa-onnx/pascal-api/sherpa_onnx.pas (1)

104-118: Pascal ZipVoice Encoder/Decoder/Lexicon mapping is coherent end‑to‑end

The Pascal API now consistently uses Encoder/Decoder/Lexicon:

  • Public record, C-interop record, ToString, and TSherpaOnnxOfflineTts.Create all agree on field names and order.
    Interoperability with the C struct remains sound.

Also applies to: 984-995, 2422-2438, 2530-2539

sherpa-onnx/c-api/cxx-api.cc (1)

416-425: OfflineTts C++ ZipVoice encoder/decoder mapping looks correct

OfflineTts::Create now forwards config.model.zipvoice.encoder/decoder into c.model.zipvoice.encoder/decoder, matching the updated C API struct; other ZipVoice fields are unchanged and correctly wired.

sherpa-onnx/csrc/sherpa-onnx-offline-zeroshot-tts.cc (1)

23-47: Updated CLI example correctly reflects new ZipVoice flags

The usage block now demonstrates --zipvoice-encoder, --zipvoice-decoder, --zipvoice-lexicon, --zipvoice-tokens, and --zipvoice-vocoder consistent with the new ZipVoice configuration; no behavioral changes to main logic.

go-api-examples/non-streaming-tts/main.go (1)

52-58: Go ZipVoice flags now target Encoder/Decoder/Lexicon fields correctly

The Go example’s CLI now populates OfflineTtsZipVoiceModelConfig.Encoder/Decoder/Lexicon via --zipvoice-encoder/--zipvoice-decoder/--zipvoice-lexicon, aligning with the binding changes; the zero‑shot GenerateWithZipvoice path reuses these without further changes.

Also applies to: 64-68

python-api-examples/offline-zeroshot-tts.py (2)

19-20: LGTM! CLI interface updated consistently.

The renaming from --zipvoice-text-model and --zipvoice-flow-matching-model to --zipvoice-encoder and --zipvoice-decoder is applied consistently in both the usage example and argument definitions. The help text accurately reflects the new naming.

Also applies to: 52-63


238-239: LGTM! Configuration construction properly uses renamed fields.

The OfflineTtsZipvoiceModelConfig is correctly instantiated with the new encoder and decoder parameters.

scripts/go/sherpa_onnx.go (2)

963-968: LGTM! Struct definition updated with clear field names.

The OfflineTtsZipvoiceModelConfig struct now uses the more concise Encoder and Decoder field names with appropriately updated comments.


1139-1143: LGTM! C interop updated correctly.

The C string conversion and memory management properly use the renamed Encoder and Decoder fields from the Go config struct.

sherpa-onnx/csrc/offline-tts-zipvoice-model-config.h (1)

17-18: LGTM! Core C++ config struct renamed consistently.

The OfflineTtsZipvoiceModelConfig struct members, constructor parameters, and initializer list are all updated to use encoder and decoder instead of the more verbose text_model and flow_matching_model. The rename improves clarity.

Also applies to: 32-39

sherpa-onnx/python/csrc/offline-tts-zipvoice-model-config.cc (1)

22-29: LGTM! Python bindings updated to match C++ rename.

The Pybind11 bindings correctly expose the renamed encoder and decoder fields, with proper argument names and default values. Python users will have access to the new field names.

flutter/sherpa_onnx/lib/src/tts.dart (3)

198-244: LGTM! Dart model class updated comprehensively.

The OfflineTtsZipVoiceModelConfig class is updated consistently:

  • Constructor parameters use encoder and decoder
  • JSON serialization/deserialization uses the correct keys
  • String representation reflects the new field names
  • Field declarations match the new naming

408-409: LGTM! Native interop and memory management updated correctly.

The FFI code properly converts the renamed encoder and decoder fields to native UTF8 strings, and the memory cleanup correctly frees these pointers.

Also applies to: 436-437


39-46: Nice formatting improvement!

Adding trailing commas to the toJson map literals is a good Dart practice that improves code formatting and makes future diffs cleaner when adding new fields.

Also applies to: 88-95, 137-144, 181-186, 230-240

Comment on lines +6 to +10
if [ ! -f ./sherpa-onnx-zipvoice-distill-int8-zh-en-emilia/fm_decoder.onnx ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
tar xf sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
rm sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Update the file existence check to match the new int8 model filenames.

Line 6 checks for fm_decoder.onnx, which is the old filename from the non-int8 model. However, the int8 model variant (downloaded on line 7) contains decoder.int8.onnx. Subsequent script runs will fail to find the check file and unnecessarily re-download the model.

Apply this diff to fix the file existence check:

-if [ ! -f ./sherpa-onnx-zipvoice-distill-int8-zh-en-emilia/fm_decoder.onnx ]; then
+if [ ! -f ./sherpa-onnx-zipvoice-distill-int8-zh-en-emilia/decoder.int8.onnx ]; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ ! -f ./sherpa-onnx-zipvoice-distill-int8-zh-en-emilia/fm_decoder.onnx ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
tar xf sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
rm sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
fi
if [ ! -f ./sherpa-onnx-zipvoice-distill-int8-zh-en-emilia/decoder.int8.onnx ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
tar xf sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
rm sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
fi
🤖 Prompt for AI Agents
In go-api-examples/non-streaming-tts/run-zipvoice.sh around lines 6 to 10 the
file-existence check uses the old non-int8 name `fm_decoder.onnx`; update that
check to the int8 model filename `decoder.int8.onnx` so the script detects the
downloaded int8 tarball correctly and avoids re-downloading; leave the curl, tar
and rm steps unchanged.

@csukuangfj
csukuangfj merged commit a6a36e8 into k2-fsa:master Dec 11, 2025
9 of 27 checks passed
@csukuangfj
csukuangfj deleted the refactor-zipvoice-rename branch December 11, 2025 12:30
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