Skip to content

Add punctuation examples for Flutter - #3846

Merged
csukuangfj merged 4 commits into
k2-fsa:masterfrom
csukuangfj:flutter-punctuation
Aug 7, 2026
Merged

csukuangfj merged 4 commits into
k2-fsa:masterfrom
csukuangfj:flutter-punctuation

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added Flutter examples for offline and online punctuation.
    • Added punctuation editing, clearing, copying, examples, status reporting, and model information screens.
    • Added support for Android, iOS, macOS, Linux, Windows, and web.
    • Enabled browser-based punctuation processing with WASM.
  • Bug Fixes
    • Improved web model data handling and punctuation resource cleanup.
    • Added WASM compatibility for synchronous thread-pool operation.
  • Documentation
    • Added setup, model download, asset generation, performance, and platform build instructions.
  • Chores
    • Added project configuration, launch assets, packaging metadata, and platform runners.

@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Aug 7, 2026
@csukuangfj
csukuangfj requested a lite review from Copilot August 7, 2026 05:35
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds offline and online Flutter punctuation examples for Android, iOS, Linux, macOS, Windows, and web. It adds native isolate and web-worker processing, WASM punctuation bindings, model loading, platform runners, build configuration, and documentation.

Changes

WASM punctuation runtime

Layer / File(s) Summary
WASM bindings and memory handling
flutter/sherpa_onnx/lib/src/web/*, wasm/nodejs/*, flutter-examples/tts/lib/worker_web.dart
Adds web punctuation factories, WASM calls, UTF-8 buffer management, idempotent cleanup, model-property compatibility, and typed-array handling.
WASM build support
cmake/simple-sentencepiece.cmake
Adds a synchronous ThreadPool stub for WASM builds.

Offline punctuation application

Layer / File(s) Summary
Model and processing pipeline
flutter-examples/offline-punctuation/lib/model*.dart, lib/punct_manager.dart, lib/worker_*.dart
Adds model preparation, native isolate processing, web-worker processing, lifecycle management, result streams, and error handling.
Punctuation interface
flutter-examples/offline-punctuation/lib/main.dart, lib/punct_controls.dart, lib/punct_screen.dart
Adds the Material 3 UI, punctuation controls, model information, status output, and resource cleanup.
Platform projects and documentation
flutter-examples/offline-punctuation/android/*, ios/*, linux/*, macos/*, windows/*, web/*, README.md, pubspec.yaml
Adds Flutter project metadata, platform runners, build files, web assets, model instructions, and application configuration.

Online punctuation application

Layer / File(s) Summary
Model and processing pipeline
flutter-examples/online-punctuation/lib/model*.dart, lib/punct_manager.dart, lib/worker_*.dart
Adds online model preparation, native isolate processing, web-worker processing, lifecycle management, result streams, and error handling.
Punctuation interface
flutter-examples/online-punctuation/lib/main.dart, lib/punct_controls.dart, lib/punct_screen.dart
Adds the Material 3 UI, punctuation controls, model information, status output, and resource cleanup.
Platform projects and documentation
flutter-examples/online-punctuation/android/*, ios/*, linux/*, macos/*, windows/*, web/*, README.md, pubspec.yaml
Adds Flutter project metadata, platform runners, build files, web assets, model instructions, and application configuration.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant PunctScreen
  participant PunctManager
  participant WebWorker
  participant NativeIsolate
  participant WASM
  User->>PunctScreen: submit text
  PunctScreen->>PunctManager: initialize and punctuate
  PunctManager->>WebWorker: send request on web
  PunctManager->>NativeIsolate: send request on native
  WebWorker->>WASM: process text
  NativeIsolate->>WASM: process text when using web bindings
  WASM-->>WebWorker: return punctuated text
  NativeIsolate-->>PunctManager: return punctuated text and elapsed time
  WebWorker-->>PunctManager: return punctuated text and elapsed time
  PunctManager-->>PunctScreen: publish result and status
  PunctScreen-->>User: display punctuated text
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the primary change: adding Flutter punctuation examples.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@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: 15

Note

Due to the large number of review comments, Critical, Major severity comments were prioritized as inline comments.

🟡 Minor comments (7)
flutter-examples/offline-punctuation/web/punct-worker.js-111-133 (1)

111-133: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Free textPtr in finally and report an early punctuate failure.

punctuate is only processed while punct exists. If the worker later receives dispose while a punctuate message is in flight, the message matches no branch and produces no reply. If the call between Module._malloc() and free throws, Module._free(textPtr) also runs after the worker has already sent an error message. Move the free into finally, send an error when the request cannot be handled, and terminate the request path before the main message handling returns.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/offline-punctuation/web/punct-worker.js` around lines 111 -
133, Update the punctuate handling around the message dispatcher so requests
received without an available punct instance send an error response and return
immediately. Scope textPtr so the allocation is released from a finally block on
every path, including exceptions between Module._malloc and the current cleanup,
while preserving result-text cleanup and normal result responses.
flutter-examples/online-punctuation/lib/punct_controls.dart-37-75 (1)

37-75: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prevent input changes during processing.

The input field, Clear button, and Example button remain active while a request runs. A result can then apply to text that differs from the submitted request.

Set the input field to read-only while isProcessing is true. Disable Clear and Example during that state, or attach request IDs and discard stale results.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/lib/punct_controls.dart` around lines 37
- 75, Update the controls around the input TextField and the onClear/onExample
buttons to prevent edits while isProcessing is true: set the TextField read-only
and disable Clear and Example during processing, while preserving their existing
behavior otherwise.
flutter-examples/online-punctuation/lib/punct_manager.dart-100-113 (1)

100-113: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Close the native receive port before closing the controllers.

receivePort and its listener remain active after dispose(). A queued _PunctDone or _WorkerError can call .add() after _resultController or _logController closes.

Store the ReceivePort and its subscription. Cancel the subscription and close the port before closing the stream controllers.

Also applies to: 160-185

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/lib/punct_manager.dart` around lines 100
- 113, Update the isolate lifecycle in dispose() and the corresponding
initialization flow to retain the ReceivePort and its listener subscription.
Cancel the subscription and close the ReceivePort before closing _logController
and _resultController, preventing queued _PunctDone or _WorkerError callbacks
from adding to closed controllers.
flutter-examples/online-punctuation/README.md-21-38 (1)

21-38: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Specify a language for both example text blocks.

markdownlint reports MD040 for the fences on Lines 21 and 38. Add text to both opening fences.

Proposed fix
-```
+```text
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/README.md` around lines 21 - 38, Update
both fenced example text blocks in the README to use an explicit text language
identifier on their opening fences, including the input paragraph and output
text block.

Source: Linters/SAST tools

flutter-examples/online-punctuation/lib/model_web.dart-3-5 (1)

3-5: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Require Flutter SDK levels that support this web code.

flutter-examples/online-punctuation/pubspec.yaml only requires flutter: ">=2.8.1" while the web sources import dart:js_interop, dart:js_interop_unsafe, and package:web, which are unavailable in Flutter 2.8.1. Raise the project SDK constraint or add platform-aware code that supports the lower SDK.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/lib/model_web.dart` around lines 3 - 5,
Raise the Flutter SDK constraint in
flutter-examples/online-punctuation/pubspec.yaml to a version supporting
dart:js_interop, dart:js_interop_unsafe, and package:web, preserving the
existing web implementations in model_web.dart and worker_web.dart without
adding lower-SDK compatibility code.
flutter-examples/online-punctuation/web/punct-worker.js-117-127 (1)

117-127: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Release request buffers on every error path.

After line 118 allocates textPtr, an exception from encoding, native punctuation, or UTF-8 conversion skips lines 124-127. Each failed request then retains WASM heap memory.

Move both frees into a finally block.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/web/punct-worker.js` around lines 117 -
127, Update the request-processing flow around textPtr and resultPtr so both
allocated buffers are released in a finally block, including when encoding,
native punctuation, or UTF-8 conversion throws. Preserve the existing
conditional release for resultPtr and always release textPtr after the attempt.
flutter-examples/online-punctuation/web/punct-worker.js-96-105 (1)

96-105: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Keep initialization state and ownership valid on failure.

Line 98 assigns punct before the handle check. If creation returns zero, punctuate accepts the non-null object and calls the native API with a zero handle. If native creation throws, line 100 does not free the configuration buffers.

Store the handle locally. Free config in a finally block. Assign punct only after a nonzero handle is confirmed.

Proposed fix
       const config = initSherpaOnnxOnlinePunctuationConfig(msg.config, Module);
-      punct = {
-        handle: Module._SherpaOnnxCreateOnlinePunctuation(config.ptr),
-      };
-      freeConfig(config, Module);
+      let handle = 0;
+      try {
+        handle = Module._SherpaOnnxCreateOnlinePunctuation(config.ptr);
+      } finally {
+        freeConfig(config, Module);
+      }
 
-      if (!punct.handle) {
+      if (!handle) {
         self.postMessage({ type: 'error', message: 'Failed to create punctuation (null handle)' });
         return;
       }
+      punct = { handle: handle };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/web/punct-worker.js` around lines 96 -
105, Update the initialization flow around initSherpaOnnxOnlinePunctuationConfig
and _SherpaOnnxCreateOnlinePunctuation to store the native handle locally, free
config in a finally block even when creation throws, and assign punct only after
confirming the handle is nonzero. Preserve the existing error message and return
behavior for failed creation.
🧹 Nitpick comments (1)
flutter-examples/offline-punctuation/README.md (1)

21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add language identifiers to the text examples.

Add text after both opening fences. This satisfies MD040 and preserves the rendered output.

Proposed change
-```
+```text
 yesterday afternoon 我去了一家 near my apartment 的 coffee shop 想要
 ...
-```
+```

-```
+```text
 yesterday afternoon,我去了一家near my apartment的coffee shop,想要
 ...
-```
+```

Also applies to: 32-32

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/offline-punctuation/README.md` at line 21, Add the text
language identifier to both opening Markdown code fences in the README examples,
including the second occurrence, while leaving the example contents and rendered
output unchanged.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@flutter-examples/offline-punctuation/lib/model_web.dart`:
- Around line 3-5: Update the SDK constraint for the offline-punctuation example
to require Dart >=3.3.0, covering the JS interop imports used by model_web.dart
and worker_web.dart; keep the existing dart:js_interop, dart:js_interop_unsafe,
and package:web usage unchanged.

In `@flutter-examples/offline-punctuation/lib/punct_controls.dart`:
- Around line 37-75: Update the widget controls around the input TextField and
the onClear/onExample buttons so input mutations are disabled while isProcessing
is true: prevent editing the input and disable both Clear and Example, while
preserving the existing Punctuate loading behavior. Ensure the active request
cannot be overwritten by changes made during processing.

In `@flutter-examples/offline-punctuation/lib/punct_manager.dart`:
- Around line 71-80: Update PunctManager.init() to store the in-progress
initialization Future when transitioning to PunctState.initializing, and have
subsequent callers await that same Future instead of returning immediately.
Ensure both _initWeb() and _initNative() are covered, while preserving the
existing initialized fast path so punctuate() cannot run before setup completes.
- Around line 131-143: Publish initialization failures at
flutter-examples/offline-punctuation/lib/punct_manager.dart:131-143 and runtime
worker failures at
flutter-examples/offline-punctuation/lib/punct_manager.dart:176-181 through one
structured error result or error stream, rather than only _logController. In
flutter-examples/offline-punctuation/lib/punct_screen.dart:54-75, check
isInitialized before dispatching punctuation and reset _isProcessing when the
manager reports that error.

In `@flutter-examples/offline-punctuation/test/widget_test.dart`:
- Around line 14-28: Replace the default counter test around the testWidgets
callback with coverage for PunctScreen and InfoScreen. Remove the 0/1 text and
Icons.add assertions, and instead locate the stable PunctControls Input, Result,
and Punctuate UI targets to verify the punctuation flow; add field/action
identifiers only if those labels are not sufficient.

In `@flutter-examples/offline-punctuation/web/punct-worker.js`:
- Around line 100-103: In the null-handle branch of the punctuation
initialization flow, set the `punct` state to `null` before posting the error
and returning. Keep the existing error message and control flow unchanged so
later `punctuate` and cleanup handlers cannot use or destroy the invalid handle.

In `@flutter-examples/offline-punctuation/windows/runner/utils.cpp`:
- Around line 48-57: Update the UTF-16 conversion logic around
WideCharToMultiByte so its first return value is validated for zero before
subtracting the trailing null terminator. Only compute target_length after
confirming a successful, nonzero result, preserving the existing max_size guard
and resize behavior in the conversion helper.

In `@flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.pbxproj`:
- Around line 379-386: Remove the hard-coded DEVELOPMENT_TEAM setting from all
affected build configurations in the Xcode project, including the repeated
entries referenced by the comment. Leave signing team selection to local or
untracked configuration without changing the surrounding build settings.

In `@flutter-examples/online-punctuation/lib/punct_screen.dart`:
- Around line 41-79: Update _initIfNeeded() to return whether initialization
succeeded, and have _onPunctuate() stop before setting _isProcessing or calling
punctuate when initialization fails. Add a manager error event for failed
requests, subscribe to it in the screen setup, and have its handler reset
_isProcessing while updating the log appropriately.

In `@flutter-examples/online-punctuation/lib/worker_web.dart`:
- Around line 63-79: Update the worker initialization flow around initMsg and
_worker!.postMessage to transfer, rather than clone, wasmData.buffer and every
model buffer stored in jsModelFiles. Build a transfer list containing the WASM
ArrayBuffer and all model ArrayBuffers, pass it to postMessage, and avoid
accessing those buffers after the transfer.

In `@flutter-examples/online-punctuation/pubspec.yaml`:
- Around line 27-28: Add the punctuation model asset directory under the Flutter
assets configuration in pubspec.yaml, and update generate-asset-list.py so its
generated asset list remains synchronized with the bundled model files. Ensure
the existing cnnBiLstm and bpeVocab asset paths resolve from the bundled model
directory.

In `@flutter-examples/online-punctuation/test/widget_test.dart`:
- Around line 14-28: Replace the copied counter test in MyApp’s widget test with
assertions matching the punctuation app’s Home Page, PunctScreen, or InfoScreen
UI, removing the invalid counter text and add-icon interactions. In
flutter-examples/online-punctuation/pubspec.yaml lines 27-28, add flutter_test
under dev_dependencies if this test remains part of the package.

In `@flutter-examples/online-punctuation/windows/runner/utils.cpp`:
- Around line 48-57: Update the conversion sizing logic near WideCharToMultiByte
to store its result in a signed variable, return the empty string immediately
when the sizing call returns 0, and only then compute target_length as
required_length minus one. Preserve the existing max_size validation before
resizing utf8_string.

In `@flutter-examples/tts/lib/worker_web.dart`:
- Around line 134-138: Update _loadAssetBytes to return a compacted Uint8List
copy of the asset range, ensuring callers using wasmData.buffer.toJS receive
only the asset bytes rather than the underlying buffer. Preserve the existing
asset loading and range selection behavior.

In `@flutter/sherpa_onnx/lib/src/web/tts.dart`:
- Around line 82-86: Update the referenceAudio assignment in the TTS generation
configuration block to convert the Dart Float32List with .toJS before storing it
in genConfig, replacing the unsafe as JSAny cast while preserving the existing
null and non-empty checks.

---

Minor comments:
In `@flutter-examples/offline-punctuation/web/punct-worker.js`:
- Around line 111-133: Update the punctuate handling around the message
dispatcher so requests received without an available punct instance send an
error response and return immediately. Scope textPtr so the allocation is
released from a finally block on every path, including exceptions between
Module._malloc and the current cleanup, while preserving result-text cleanup and
normal result responses.

In `@flutter-examples/online-punctuation/lib/model_web.dart`:
- Around line 3-5: Raise the Flutter SDK constraint in
flutter-examples/online-punctuation/pubspec.yaml to a version supporting
dart:js_interop, dart:js_interop_unsafe, and package:web, preserving the
existing web implementations in model_web.dart and worker_web.dart without
adding lower-SDK compatibility code.

In `@flutter-examples/online-punctuation/lib/punct_controls.dart`:
- Around line 37-75: Update the controls around the input TextField and the
onClear/onExample buttons to prevent edits while isProcessing is true: set the
TextField read-only and disable Clear and Example during processing, while
preserving their existing behavior otherwise.

In `@flutter-examples/online-punctuation/lib/punct_manager.dart`:
- Around line 100-113: Update the isolate lifecycle in dispose() and the
corresponding initialization flow to retain the ReceivePort and its listener
subscription. Cancel the subscription and close the ReceivePort before closing
_logController and _resultController, preventing queued _PunctDone or
_WorkerError callbacks from adding to closed controllers.

In `@flutter-examples/online-punctuation/README.md`:
- Around line 21-38: Update both fenced example text blocks in the README to use
an explicit text language identifier on their opening fences, including the
input paragraph and output text block.

In `@flutter-examples/online-punctuation/web/punct-worker.js`:
- Around line 117-127: Update the request-processing flow around textPtr and
resultPtr so both allocated buffers are released in a finally block, including
when encoding, native punctuation, or UTF-8 conversion throws. Preserve the
existing conditional release for resultPtr and always release textPtr after the
attempt.
- Around line 96-105: Update the initialization flow around
initSherpaOnnxOnlinePunctuationConfig and _SherpaOnnxCreateOnlinePunctuation to
store the native handle locally, free config in a finally block even when
creation throws, and assign punct only after confirming the handle is nonzero.
Preserve the existing error message and return behavior for failed creation.

---

Nitpick comments:
In `@flutter-examples/offline-punctuation/README.md`:
- Line 21: Add the text language identifier to both opening Markdown code fences
in the README examples, including the second occurrence, while leaving the
example contents and rendered output unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dc3e5a47-199c-43ad-b581-99a7c856d046

📥 Commits

Reviewing files that changed from the base of the PR and between fa76497 and b75258d.

⛔ Files ignored due to path filters (78)
  • flutter-examples/offline-punctuation/android/app/src/main/res/mipmap-hdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/android/app/src/main/res/mipmap-mdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata is excluded by !**/*.xcworkspace/contents.xcworkspacedata
  • flutter-examples/offline-punctuation/ios/Runner.xcworkspace/contents.xcworkspacedata is excluded by !**/*.xcworkspace/contents.xcworkspacedata
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/macos/Runner.xcworkspace/contents.xcworkspacedata is excluded by !**/*.xcworkspace/contents.xcworkspacedata
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/web/favicon.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/web/icons/Icon-192.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/web/icons/Icon-512.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/web/icons/Icon-maskable-192.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/web/icons/Icon-maskable-512.png is excluded by !**/*.png
  • flutter-examples/offline-punctuation/windows/runner/resources/app_icon.ico is excluded by !**/*.ico
  • flutter-examples/online-punctuation/android/app/src/main/res/mipmap-hdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/android/app/src/main/res/mipmap-mdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata is excluded by !**/*.xcworkspace/contents.xcworkspacedata
  • flutter-examples/online-punctuation/ios/Runner.xcworkspace/contents.xcworkspacedata is excluded by !**/*.xcworkspace/contents.xcworkspacedata
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/macos/Runner.xcworkspace/contents.xcworkspacedata is excluded by !**/*.xcworkspace/contents.xcworkspacedata
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/web/favicon.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/web/icons/Icon-192.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/web/icons/Icon-512.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/web/icons/Icon-maskable-192.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/web/icons/Icon-maskable-512.png is excluded by !**/*.png
  • flutter-examples/online-punctuation/windows/runner/resources/app_icon.ico is excluded by !**/*.ico
📒 Files selected for processing (194)
  • cmake/simple-sentencepiece.cmake
  • flutter-examples/offline-punctuation/.gitignore
  • flutter-examples/offline-punctuation/.metadata
  • flutter-examples/offline-punctuation/README.md
  • flutter-examples/offline-punctuation/analysis_options.yaml
  • flutter-examples/offline-punctuation/android/.gitignore
  • flutter-examples/offline-punctuation/android/app/build.gradle.kts
  • flutter-examples/offline-punctuation/android/app/src/debug/AndroidManifest.xml
  • flutter-examples/offline-punctuation/android/app/src/main/AndroidManifest.xml
  • flutter-examples/offline-punctuation/android/app/src/main/kotlin/com/example/offline_punctuation/MainActivity.kt
  • flutter-examples/offline-punctuation/android/app/src/main/res/drawable-v21/launch_background.xml
  • flutter-examples/offline-punctuation/android/app/src/main/res/drawable/launch_background.xml
  • flutter-examples/offline-punctuation/android/app/src/main/res/values-night/styles.xml
  • flutter-examples/offline-punctuation/android/app/src/main/res/values/styles.xml
  • flutter-examples/offline-punctuation/android/app/src/profile/AndroidManifest.xml
  • flutter-examples/offline-punctuation/android/build.gradle.kts
  • flutter-examples/offline-punctuation/android/gradle.properties
  • flutter-examples/offline-punctuation/android/gradle/wrapper/gradle-wrapper.properties
  • flutter-examples/offline-punctuation/android/settings.gradle.kts
  • flutter-examples/offline-punctuation/assets/.gitkeep
  • flutter-examples/offline-punctuation/generate-asset-list.py
  • flutter-examples/offline-punctuation/ios/.gitignore
  • flutter-examples/offline-punctuation/ios/Flutter/AppFrameworkInfo.plist
  • flutter-examples/offline-punctuation/ios/Flutter/Debug.xcconfig
  • flutter-examples/offline-punctuation/ios/Flutter/Release.xcconfig
  • flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.pbxproj
  • flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
  • flutter-examples/offline-punctuation/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  • flutter-examples/offline-punctuation/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/offline-punctuation/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
  • flutter-examples/offline-punctuation/ios/Runner/AppDelegate.swift
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
  • flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
  • flutter-examples/offline-punctuation/ios/Runner/Base.lproj/LaunchScreen.storyboard
  • flutter-examples/offline-punctuation/ios/Runner/Base.lproj/Main.storyboard
  • flutter-examples/offline-punctuation/ios/Runner/Info.plist
  • flutter-examples/offline-punctuation/ios/Runner/Runner-Bridging-Header.h
  • flutter-examples/offline-punctuation/ios/Runner/SceneDelegate.swift
  • flutter-examples/offline-punctuation/ios/RunnerTests/RunnerTests.swift
  • flutter-examples/offline-punctuation/lib/main.dart
  • flutter-examples/offline-punctuation/lib/model.dart
  • flutter-examples/offline-punctuation/lib/model_config.dart
  • flutter-examples/offline-punctuation/lib/model_web.dart
  • flutter-examples/offline-punctuation/lib/punct_controls.dart
  • flutter-examples/offline-punctuation/lib/punct_manager.dart
  • flutter-examples/offline-punctuation/lib/punct_screen.dart
  • flutter-examples/offline-punctuation/lib/worker_stub.dart
  • flutter-examples/offline-punctuation/lib/worker_web.dart
  • flutter-examples/offline-punctuation/linux/.gitignore
  • flutter-examples/offline-punctuation/linux/CMakeLists.txt
  • flutter-examples/offline-punctuation/linux/flutter/CMakeLists.txt
  • flutter-examples/offline-punctuation/linux/runner/CMakeLists.txt
  • flutter-examples/offline-punctuation/linux/runner/main.cc
  • flutter-examples/offline-punctuation/linux/runner/my_application.cc
  • flutter-examples/offline-punctuation/linux/runner/my_application.h
  • flutter-examples/offline-punctuation/macos/.gitignore
  • flutter-examples/offline-punctuation/macos/Flutter/Flutter-Debug.xcconfig
  • flutter-examples/offline-punctuation/macos/Flutter/Flutter-Release.xcconfig
  • flutter-examples/offline-punctuation/macos/Runner.xcodeproj/project.pbxproj
  • flutter-examples/offline-punctuation/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/offline-punctuation/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  • flutter-examples/offline-punctuation/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/offline-punctuation/macos/Runner/AppDelegate.swift
  • flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
  • flutter-examples/offline-punctuation/macos/Runner/Base.lproj/MainMenu.xib
  • flutter-examples/offline-punctuation/macos/Runner/Configs/AppInfo.xcconfig
  • flutter-examples/offline-punctuation/macos/Runner/Configs/Debug.xcconfig
  • flutter-examples/offline-punctuation/macos/Runner/Configs/Release.xcconfig
  • flutter-examples/offline-punctuation/macos/Runner/Configs/Warnings.xcconfig
  • flutter-examples/offline-punctuation/macos/Runner/DebugProfile.entitlements
  • flutter-examples/offline-punctuation/macos/Runner/Info.plist
  • flutter-examples/offline-punctuation/macos/Runner/MainFlutterWindow.swift
  • flutter-examples/offline-punctuation/macos/Runner/Release.entitlements
  • flutter-examples/offline-punctuation/macos/RunnerTests/RunnerTests.swift
  • flutter-examples/offline-punctuation/pubspec.yaml
  • flutter-examples/offline-punctuation/test/widget_test.dart
  • flutter-examples/offline-punctuation/web/index.html
  • flutter-examples/offline-punctuation/web/manifest.json
  • flutter-examples/offline-punctuation/web/punct-worker.js
  • flutter-examples/offline-punctuation/windows/.gitignore
  • flutter-examples/offline-punctuation/windows/CMakeLists.txt
  • flutter-examples/offline-punctuation/windows/flutter/CMakeLists.txt
  • flutter-examples/offline-punctuation/windows/runner/CMakeLists.txt
  • flutter-examples/offline-punctuation/windows/runner/Runner.rc
  • flutter-examples/offline-punctuation/windows/runner/flutter_window.cpp
  • flutter-examples/offline-punctuation/windows/runner/flutter_window.h
  • flutter-examples/offline-punctuation/windows/runner/main.cpp
  • flutter-examples/offline-punctuation/windows/runner/resource.h
  • flutter-examples/offline-punctuation/windows/runner/runner.exe.manifest
  • flutter-examples/offline-punctuation/windows/runner/utils.cpp
  • flutter-examples/offline-punctuation/windows/runner/utils.h
  • flutter-examples/offline-punctuation/windows/runner/win32_window.cpp
  • flutter-examples/offline-punctuation/windows/runner/win32_window.h
  • flutter-examples/online-punctuation/.gitignore
  • flutter-examples/online-punctuation/.metadata
  • flutter-examples/online-punctuation/README.md
  • flutter-examples/online-punctuation/analysis_options.yaml
  • flutter-examples/online-punctuation/android/.gitignore
  • flutter-examples/online-punctuation/android/app/build.gradle.kts
  • flutter-examples/online-punctuation/android/app/src/debug/AndroidManifest.xml
  • flutter-examples/online-punctuation/android/app/src/main/AndroidManifest.xml
  • flutter-examples/online-punctuation/android/app/src/main/kotlin/com/example/online_punctuation/MainActivity.kt
  • flutter-examples/online-punctuation/android/app/src/main/res/drawable-v21/launch_background.xml
  • flutter-examples/online-punctuation/android/app/src/main/res/drawable/launch_background.xml
  • flutter-examples/online-punctuation/android/app/src/main/res/values-night/styles.xml
  • flutter-examples/online-punctuation/android/app/src/main/res/values/styles.xml
  • flutter-examples/online-punctuation/android/app/src/profile/AndroidManifest.xml
  • flutter-examples/online-punctuation/android/build.gradle.kts
  • flutter-examples/online-punctuation/android/gradle.properties
  • flutter-examples/online-punctuation/android/gradle/wrapper/gradle-wrapper.properties
  • flutter-examples/online-punctuation/android/settings.gradle.kts
  • flutter-examples/online-punctuation/assets/.gitkeep
  • flutter-examples/online-punctuation/generate-asset-list.py
  • flutter-examples/online-punctuation/ios/.gitignore
  • flutter-examples/online-punctuation/ios/Flutter/AppFrameworkInfo.plist
  • flutter-examples/online-punctuation/ios/Flutter/Debug.xcconfig
  • flutter-examples/online-punctuation/ios/Flutter/Release.xcconfig
  • flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.pbxproj
  • flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
  • flutter-examples/online-punctuation/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  • flutter-examples/online-punctuation/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/online-punctuation/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
  • flutter-examples/online-punctuation/ios/Runner/AppDelegate.swift
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
  • flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
  • flutter-examples/online-punctuation/ios/Runner/Base.lproj/LaunchScreen.storyboard
  • flutter-examples/online-punctuation/ios/Runner/Base.lproj/Main.storyboard
  • flutter-examples/online-punctuation/ios/Runner/Info.plist
  • flutter-examples/online-punctuation/ios/Runner/Runner-Bridging-Header.h
  • flutter-examples/online-punctuation/ios/Runner/SceneDelegate.swift
  • flutter-examples/online-punctuation/ios/RunnerTests/RunnerTests.swift
  • flutter-examples/online-punctuation/lib/main.dart
  • flutter-examples/online-punctuation/lib/model.dart
  • flutter-examples/online-punctuation/lib/model_config.dart
  • flutter-examples/online-punctuation/lib/model_web.dart
  • flutter-examples/online-punctuation/lib/punct_controls.dart
  • flutter-examples/online-punctuation/lib/punct_manager.dart
  • flutter-examples/online-punctuation/lib/punct_screen.dart
  • flutter-examples/online-punctuation/lib/worker_stub.dart
  • flutter-examples/online-punctuation/lib/worker_web.dart
  • flutter-examples/online-punctuation/linux/.gitignore
  • flutter-examples/online-punctuation/linux/CMakeLists.txt
  • flutter-examples/online-punctuation/linux/flutter/CMakeLists.txt
  • flutter-examples/online-punctuation/linux/runner/CMakeLists.txt
  • flutter-examples/online-punctuation/linux/runner/main.cc
  • flutter-examples/online-punctuation/linux/runner/my_application.cc
  • flutter-examples/online-punctuation/linux/runner/my_application.h
  • flutter-examples/online-punctuation/macos/.gitignore
  • flutter-examples/online-punctuation/macos/Flutter/Flutter-Debug.xcconfig
  • flutter-examples/online-punctuation/macos/Flutter/Flutter-Release.xcconfig
  • flutter-examples/online-punctuation/macos/Runner.xcodeproj/project.pbxproj
  • flutter-examples/online-punctuation/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/online-punctuation/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  • flutter-examples/online-punctuation/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  • flutter-examples/online-punctuation/macos/Runner/AppDelegate.swift
  • flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
  • flutter-examples/online-punctuation/macos/Runner/Base.lproj/MainMenu.xib
  • flutter-examples/online-punctuation/macos/Runner/Configs/AppInfo.xcconfig
  • flutter-examples/online-punctuation/macos/Runner/Configs/Debug.xcconfig
  • flutter-examples/online-punctuation/macos/Runner/Configs/Release.xcconfig
  • flutter-examples/online-punctuation/macos/Runner/Configs/Warnings.xcconfig
  • flutter-examples/online-punctuation/macos/Runner/DebugProfile.entitlements
  • flutter-examples/online-punctuation/macos/Runner/Info.plist
  • flutter-examples/online-punctuation/macos/Runner/MainFlutterWindow.swift
  • flutter-examples/online-punctuation/macos/Runner/Release.entitlements
  • flutter-examples/online-punctuation/macos/RunnerTests/RunnerTests.swift
  • flutter-examples/online-punctuation/pubspec.yaml
  • flutter-examples/online-punctuation/test/widget_test.dart
  • flutter-examples/online-punctuation/web/index.html
  • flutter-examples/online-punctuation/web/manifest.json
  • flutter-examples/online-punctuation/web/punct-worker.js
  • flutter-examples/online-punctuation/windows/.gitignore
  • flutter-examples/online-punctuation/windows/CMakeLists.txt
  • flutter-examples/online-punctuation/windows/flutter/CMakeLists.txt
  • flutter-examples/online-punctuation/windows/runner/CMakeLists.txt
  • flutter-examples/online-punctuation/windows/runner/Runner.rc
  • flutter-examples/online-punctuation/windows/runner/flutter_window.cpp
  • flutter-examples/online-punctuation/windows/runner/flutter_window.h
  • flutter-examples/online-punctuation/windows/runner/main.cpp
  • flutter-examples/online-punctuation/windows/runner/resource.h
  • flutter-examples/online-punctuation/windows/runner/runner.exe.manifest
  • flutter-examples/online-punctuation/windows/runner/utils.cpp
  • flutter-examples/online-punctuation/windows/runner/utils.h
  • flutter-examples/online-punctuation/windows/runner/win32_window.cpp
  • flutter-examples/online-punctuation/windows/runner/win32_window.h
  • flutter-examples/tts/lib/worker_web.dart
  • flutter/sherpa_onnx/lib/src/web/offline_punctuation.dart
  • flutter/sherpa_onnx/lib/src/web/online_punctuation.dart
  • flutter/sherpa_onnx/lib/src/web/tts.dart
  • wasm/nodejs/sherpa-onnx-punctuation.js

Comment on lines +3 to +5
import 'dart:convert';
import 'dart:js_interop';
import 'dart:js_interop_unsafe';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '/^environment:/,/^[^[:space:]]/p' \
  flutter-examples/offline-punctuation/pubspec.yaml

rg -n -C 2 \
  'dart:js_interop|dart:js_interop_unsafe|package:web' \
  flutter-examples/offline-punctuation

Repository: k2-fsa/sherpa-onnx

Length of output: 1622


🌐 Web query:

Dart dart:js_interop stable release version Dart 3.3 package web Dart 3.3

💡 Result:

Dart 3.3 was released on February 15, 2024, and introduced a new, stable model for JavaScript interop, which included both the dart:js_interop library and the package:web package [1][2]. The key components of this release are: 1. dart:js_interop: This library was introduced in Dart 3.3 as the new, typed, and sound mechanism for interacting with JavaScript [1][3]. It uses Dart's extension types to provide a consistent and idiomatic way to define the boundary between Dart and JavaScript, supporting both JavaScript and WebAssembly (Wasm) compilation targets [3][4]. 2. package:web: Released alongside Dart 3.3, this package provides lightweight browser API bindings built on top of dart:js_interop [3][5]. It is intended to replace legacy browser libraries such as dart:html, which are now deprecated [6][4][5]. package:web aligns with MDN (Mozilla Developer Network) resources and is the recommended way to access browser APIs in modern Dart applications [1][7]. While documentation within the Dart SDK repository for version 3.3.0 contained a warning label regarding the library being a work in progress [8], the official release announcement and subsequent development confirm that dart:js_interop and package:web are the current, stable, and recommended standards for JavaScript interop in Dart [1][3][7]. Legacy interop libraries, including package:js and dart:html, have been deprecated as of Dart 3.7 [4].

Citations:


Align the Dart SDK constraint with the JS interop APIs.

flutter-examples/offline-punctuation/lib/model_web.dart and worker_web.dart import dart:js_interop, dart:js_interop_unsafe, and package:web. These APIs need Dart 3.3+. Raise the SDK constraint to at least >=3.3.0, or replace these APIs with the pre-3.3 web APIs allowed by the current constraint.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/offline-punctuation/lib/model_web.dart` around lines 3 - 5,
Update the SDK constraint for the offline-punctuation example to require Dart
>=3.3.0, covering the JS interop imports used by model_web.dart and
worker_web.dart; keep the existing dart:js_interop, dart:js_interop_unsafe, and
package:web usage unchanged.

Comment on lines +37 to +75
TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: 'Enter text without punctuation',
labelText: 'Input',
contentPadding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
suffixIcon: IconButton(
icon: const Icon(Icons.copy, size: 18),
tooltip: 'Copy input',
onPressed: () => _copyToClipboard(context, inputController.text),
),
),
style: const TextStyle(fontSize: 18),
maxLines: 8,
minLines: 5,
controller: inputController,
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
onPressed: isProcessing ? null : onPunctuate,
child:
Text(isProcessing ? 'Processing...' : 'Punctuate'),
),
const SizedBox(width: 8),
OutlinedButton(
onPressed: onClear,
child: const Text('Clear'),
),
if (onExample != null) ...[
const SizedBox(width: 8),
OutlinedButton(
onPressed: onExample,
child: const Text('Example'),
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Prevent result and input mismatches.

While isProcessing is true, the input remains editable and Clear and Example remain enabled. PunctResult has no request identifier. A response for earlier text can overwrite the result after the user changes or clears the input. Disable all input mutations while a request runs, or add request IDs and discard stale results.

Proposed fix
         TextField(
+          readOnly: isProcessing,
           decoration: InputDecoration(
@@
             OutlinedButton(
-              onPressed: onClear,
+              onPressed: isProcessing ? null : onClear,
               child: const Text('Clear'),
@@
               OutlinedButton(
-                onPressed: onExample,
+                onPressed: isProcessing ? null : onExample,
                 child: const Text('Example'),
📝 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
TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: 'Enter text without punctuation',
labelText: 'Input',
contentPadding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
suffixIcon: IconButton(
icon: const Icon(Icons.copy, size: 18),
tooltip: 'Copy input',
onPressed: () => _copyToClipboard(context, inputController.text),
),
),
style: const TextStyle(fontSize: 18),
maxLines: 8,
minLines: 5,
controller: inputController,
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
onPressed: isProcessing ? null : onPunctuate,
child:
Text(isProcessing ? 'Processing...' : 'Punctuate'),
),
const SizedBox(width: 8),
OutlinedButton(
onPressed: onClear,
child: const Text('Clear'),
),
if (onExample != null) ...[
const SizedBox(width: 8),
OutlinedButton(
onPressed: onExample,
child: const Text('Example'),
),
TextField(
readOnly: isProcessing,
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: 'Enter text without punctuation',
labelText: 'Input',
contentPadding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
suffixIcon: IconButton(
icon: const Icon(Icons.copy, size: 18),
tooltip: 'Copy input',
onPressed: () => _copyToClipboard(context, inputController.text),
),
),
style: const TextStyle(fontSize: 18),
maxLines: 8,
minLines: 5,
controller: inputController,
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
onPressed: isProcessing ? null : onPunctuate,
child:
Text(isProcessing ? 'Processing...' : 'Punctuate'),
),
const SizedBox(width: 8),
OutlinedButton(
onPressed: isProcessing ? null : onClear,
child: const Text('Clear'),
),
if (onExample != null) ...[
const SizedBox(width: 8),
OutlinedButton(
onPressed: isProcessing ? null : onExample,
child: const Text('Example'),
),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/offline-punctuation/lib/punct_controls.dart` around lines 37
- 75, Update the widget controls around the input TextField and the
onClear/onExample buttons so input mutations are disabled while isProcessing is
true: prevent editing the input and disable both Clear and Example, while
preserving the existing Punctuate loading behavior. Ensure the active request
cannot be overwritten by changes made during processing.

Comment on lines +71 to +80
Future<void> init() async {
if (_state != PunctState.uninitialized) return;
_state = PunctState.initializing;

if (kIsWeb) {
await _initWeb();
} else {
await _initNative();
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Make init() await ongoing initialization.

When _state is initializing, line 72 returns a completed future. A second punctuation action can then call punctuate() before the worker or SendPort is ready. punctuate() logs an error and drops that request. Store the in-progress initialization future and await it from every caller.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/offline-punctuation/lib/punct_manager.dart` around lines 71
- 80, Update PunctManager.init() to store the in-progress initialization Future
when transitioning to PunctState.initializing, and have subsequent callers await
that same Future instead of returning immediately. Ensure both _initWeb() and
_initNative() are covered, while preserving the existing initialized fast path
so punctuate() cannot run before setup completes.

Comment on lines +131 to +143
onError: (msg) {
_state = PunctState.uninitialized;
_logController.add('Error: $msg');
if (!readyCompleter.isCompleted) readyCompleter.completeError(msg);
},
);

await _worker!.init();
await readyCompleter.future;
} catch (e) {
_state = PunctState.uninitialized;
_logController.add('Error: $e');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Publish punctuation failures to the screen and clear processing state.

Worker initialization and runtime failures only update logStream. PunctScreen sets _isProcessing after initialization attempts and only resets it when a result arrives. If model loading or punctuation fails, the Punctuate button stays disabled indefinitely.

  • flutter-examples/offline-punctuation/lib/punct_manager.dart#L131-L143: Publish web initialization failures through a structured error result or error stream.
  • flutter-examples/offline-punctuation/lib/punct_manager.dart#L176-L181: Publish runtime worker failures through the same structured error path.
  • flutter-examples/offline-punctuation/lib/punct_screen.dart#L54-L75: Check isInitialized before dispatch, and reset _isProcessing when the manager reports an error.
📍 Affects 2 files
  • flutter-examples/offline-punctuation/lib/punct_manager.dart#L131-L143 (this comment)
  • flutter-examples/offline-punctuation/lib/punct_manager.dart#L176-L181
  • flutter-examples/offline-punctuation/lib/punct_screen.dart#L54-L75
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/offline-punctuation/lib/punct_manager.dart` around lines 131
- 143, Publish initialization failures at
flutter-examples/offline-punctuation/lib/punct_manager.dart:131-143 and runtime
worker failures at
flutter-examples/offline-punctuation/lib/punct_manager.dart:176-181 through one
structured error result or error stream, rather than only _logController. In
flutter-examples/offline-punctuation/lib/punct_screen.dart:54-75, check
isInitialized before dispatching punctuation and reset _isProcessing when the
manager reports that error.

Comment on lines +14 to +28
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the application and punctuation-screen widget declarations.
ast-grep outline flutter-examples/offline-punctuation/lib/main.dart --items all
ast-grep outline flutter-examples/offline-punctuation/lib/punct_screen.dart --items all

# Show stable UI labels, buttons, and test keys for a replacement test.
rg -n -C 3 --glob '*.dart' \
  "Text\(|TextField\(|ElevatedButton|FilledButton|IconButton|Key\(" \
  flutter-examples/offline-punctuation/lib

Repository: k2-fsa/sherpa-onnx

Length of output: 10246


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Relevant files =="
git ls-files flutter-examples/offline-punctuation/lib flutter-examples/offline-punctuation/test

echo
echo "== main.dart outline =="
ast-grep outline flutter-examples/offline-punctuation/lib/main.dart --view expanded || true

echo
echo "== punct_screen.dart outline =="
ast-grep outline flutter-examples/offline-punctuation/lib/punct_screen.dart --view expanded || true

echo
echo "== punct_controls.dart outline =="
ast-grep outline flutter-examples/offline-punctuation/lib/punct_controls.dart --view expanded || true

echo
echo "== Tests =="
sed -n '1,140p' flutter-examples/offline-punctuation/test/widget_test.dart

echo
echo "== MyApp/class declarations =="
rg -n -C 4 'class MyApp|PunctScreen|PunctControls|Punct|Text\(|findsOneWidget|findsNothing|Icons\.add|OutlinedButton|TextField|Result|Input' flutter-examples/offline-punctuation/lib

Repository: k2-fsa/sherpa-onnx

Length of output: 50374


Replace the default counter widget test.

The app now renders PunctScreen and InfoScreen; the counter expectations for 0, 1, and Icons.add are stale and do not validate punctuation behavior. Use stable app UI targets such as PunctControls’ Input, Result, and Punctuate labels, or add identifiers for the fields and action.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/offline-punctuation/test/widget_test.dart` around lines 14 -
28, Replace the default counter test around the testWidgets callback with
coverage for PunctScreen and InfoScreen. Remove the 0/1 text and Icons.add
assertions, and instead locate the stable PunctControls Input, Result, and
Punctuate UI targets to verify the punctuation flow; add field/action
identifiers only if those labels are not sufficient.

Comment on lines +27 to +28
flutter:
uses-material-design: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Bundle the punctuation model assets.

Native model loading copies files from AssetManifest and resolves cnnBiLstm/bpeVocab to $modelDir/$modelFile and $modelDir/$bpeVocab. Since pubspec.yaml has no assets: entries and assets/ contains only .gitkeep, these assets are not bundled and initialization uses missing paths under $modelDir.

Add the model directory to pubspec.yaml and keep generate-asset-list.py synchronized.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/pubspec.yaml` around lines 27 - 28, Add
the punctuation model asset directory under the Flutter assets configuration in
pubspec.yaml, and update generate-asset-list.py so its generated asset list
remains synchronized with the bundled model files. Ensure the existing cnnBiLstm
and bpeVocab asset paths resolve from the bundled model directory.

Comment on lines +14 to +28
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file list =="
git ls-files | rg '(^|/)flutter-examples/online-punctuation/(pubspec\.yaml|test/widget_test\.dart|lib/)')' || true

echo "== pubspec relevant =="
if [ -f flutter-examples/online-punctuation/pubspec.yaml ]; then
  cat -n flutter-examples/online-punctuation/pubspec.yaml
fi

echo "== test relevant =="
if [ -f flutter-examples/online-punctuation/test/widget_test.dart ]; then
  cat -n flutter-examples/online-punctuation/test/widget_test.dart
fi

echo "== locate online-punctuation app files =="
fd -p flutter-examples/online-punctuation/lib . | sort | while read -r f; do
  echo "--- $f"
  cat -n "$f"
done

echo "== search counter/material app terms =="
rg -n "Counter|add|Icons\.add|Online Punctuation|Punctuate|widgets\.test|flutter_test" flutter-examples/online-punctuation || true

Repository: k2-fsa/sherpa-onnx

Length of output: 225


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

path = Path("flutter-examples/online-punctuation/pubspec.yaml")
text = path.read_text()
print("pubspec flutter_test dependency present:", bool(re.search(r'^\s*flutter_test\s*:', text, re.M)))
print("pubspec uses-material-design present:", bool(re.search(r'^\s*uses-material-design:\s*true\s*$', text, re.M)))
print("pubspec dependency keys under dev_dependencies:", sorted(m.group(1) for m in re.finditer(r'^(dev_dependencies):', text, re.M)))
print("pubspec flutter_test exact:", "flutter_test:" in text)

test = Path("flutter-examples/online-punctuation/test/widget_test.dart").read_text() if Path("flutter-examples/online-punctuation/test/widget_test.dart").exists() else ""
print("widget test imports:", [line.strip() for line in test.splitlines() if line.startswith("import")])
print("widget test has byIcon(Icons.add):", "find.byIcon(Icons.add)" in test)
print("widget test has text(0):", "find.text('0')" in test)
print("widget test has text(1):", "find.text('1')" in test)
print("widget test invokes pumpWidget(MyApp):", "tester.pumpWidget(const MyApp())" in test)
PY

Repository: k2-fsa/sherpa-onnx

Length of output: 642


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== tracked online-punctuation files =="
git ls-files 'flutter-examples/online-punctuation/*' | sort

echo "== pubspec =="
if [ -f flutter-examples/online-punctuation/pubspec.yaml ]; then
  cat -n flutter-examples/online-punctuation/pubspec.yaml
fi

echo "== main/app files =="
for f in $(git ls-files 'flutter-examples/online-punctuation/lib/**' | sort); do
  echo "--- $f"
  cat -n "$f"
done

echo "== widget test =="
if [ -f flutter-examples/online-punctuation/test/widget_test.dart ]; then
  cat -n flutter-examples/online-punctuation/test/widget_test.dart
fi

echo "== relevant symbols =="
rg -n "class MyApp|Online Punctuation|Punctuate|Icons\.add|Counter|find\.text|flutter_test" flutter-examples/online-punctuation || true

Repository: k2-fsa/sherpa-onnx

Length of output: 50374


Replace the copied counter test or update it for the punctuation app.

MyApp builds Home Page, PunctScreen, and InfoScreen, so find.text('0') and find.byIcon(Icons.add) do not match the current UI. Add flutter_test under dev_dependencies if this test is intended to run as part of the package.

📍 Affects 2 files
  • flutter-examples/online-punctuation/test/widget_test.dart#L14-L28 (this comment)
  • flutter-examples/online-punctuation/pubspec.yaml#L27-L28
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/test/widget_test.dart` around lines 14 -
28, Replace the copied counter test in MyApp’s widget test with assertions
matching the punctuation app’s Home Page, PunctScreen, or InfoScreen UI,
removing the invalid counter text and add-icon interactions. In
flutter-examples/online-punctuation/pubspec.yaml lines 27-28, add flutter_test
under dev_dependencies if this test remains part of the package.

Comment on lines +48 to +57
unsigned int target_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
-1, nullptr, 0, nullptr, nullptr)
-1; // remove the trailing null character
int input_length = (int)wcslen(utf16_string);
std::string utf8_string;
if (target_length == 0 || target_length > utf8_string.max_size()) {
return utf8_string;
}
utf8_string.resize(target_length);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate utils.cpp =="
fd -a 'utils\.cpp$' . || true

echo "== relevant file excerpt =="
file="$(fd 'utils\.cpp$' . | head -n1 || true)"
if [ -n "${file:-}" ]; then
  wc -l "$file"
  sed -n '1,120p' "$file" | cat -n
fi

echo "== search for symbol/usage =="
rg -n "Utf8From|WideCharToMultiByte|utf16_string|target_length|input_length" . -S || true

echo "== git diff summary if available =="
git diff --stat || true
git diff -- "$file" | sed -n '1,160p' || true

echo "== read-only behavioral model for unsigned subtraction underflow =="
python3 - <<'PY'
import ctypes

def unsigned_sub(value, sub):
    # emulate C++ unsigned int unsigned sub behavior modulo 2**32
    return (value - sub) % (2**32)

print("WideCharToMultiByte=0:", unsigned_sub(0, 1))
print("WideCharToMultiByte=1:", unsigned_sub(1, 1))
print("resize argument with bad uint value:", unsigned_sub(0, 1))
PY

Repository: k2-fsa/sherpa-onnx

Length of output: 14797


Check WideCharToMultiByte before applying the -1 adjustment.

WideCharToMultiByte returns 0 on failure, but this stores (0U - 1), so target_length becomes UINT_MAX. If that passes utf8_string.max_size(), resize uses a huge size and can abort the runner instead of returning an empty string for invalid surrogate input.

Store the sizing call in a signed variable, return early for 0, then compute required_length - 1.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/online-punctuation/windows/runner/utils.cpp` around lines 48
- 57, Update the conversion sizing logic near WideCharToMultiByte to store its
result in a signed variable, return the empty string immediately when the sizing
call returns 0, and only then compute target_length as required_length minus
one. Preserve the existing max_size validation before resizing utf8_string.

Comment on lines 134 to 138
/// Load a Flutter asset as bytes.
static Future<Uint8List> _loadAssetBytes(String assetPath) async {
final data = await rootBundle.load(assetPath);
return data.buffer.asUint8List();
return data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

_loadAssetBytes returns a view, but the caller passes .buffer to JS.

_loadAssetBytes now correctly returns only the asset range. The caller at Line 83 still uses wasmData.buffer.toJS. ByteBuffer ignores the view offset and length, so the worker can receive the whole underlying bundle buffer instead of the WASM binary. This is the same defect that Line 71 fixes for model files.

Return a compacted copy so .buffer is always exact.

🐛 Proposed fix
   /// Load a Flutter asset as bytes.
   static Future<Uint8List> _loadAssetBytes(String assetPath) async {
     final data = await rootBundle.load(assetPath);
-    return data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
+    return Uint8List.fromList(
+        data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));
   }

Alternatively, change Line 83 to Uint8List.fromList(wasmData).buffer.toJS.

📝 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
/// Load a Flutter asset as bytes.
static Future<Uint8List> _loadAssetBytes(String assetPath) async {
final data = await rootBundle.load(assetPath);
return data.buffer.asUint8List();
return data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
}
/// Load a Flutter asset as bytes.
static Future<Uint8List> _loadAssetBytes(String assetPath) async {
final data = await rootBundle.load(assetPath);
return Uint8List.fromList(
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter-examples/tts/lib/worker_web.dart` around lines 134 - 138, Update
_loadAssetBytes to return a compacted Uint8List copy of the asset range,
ensuring callers using wasmData.buffer.toJS receive only the asset bytes rather
than the underlying buffer. Preserve the existing asset loading and range
selection behavior.

Comment thread flutter/sherpa_onnx/lib/src/web/tts.dart

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

Adds Flutter punctuation demos and improves the web/WASM punctuation and build plumbing so the examples can run across desktop/mobile/web using sherpa-onnx.

Changes:

  • Added new Flutter example apps for online and offline punctuation (UI, model loading, and platform scaffolding for Android/iOS/macOS/Linux/Windows/web).
  • Implemented web (dart:js_interop) support for OfflinePunctuation and improved worker/asset byte handling for web/WASM flows.
  • Patched simple-sentencepiece for WASM builds by stubbing out threading.

Reviewed changes

Copilot reviewed 192 out of 272 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
wasm/nodejs/sherpa-onnx-punctuation.js Accept cnnBiLstm (and legacy cnnBilstm) for online punctuation model config.
flutter/sherpa_onnx/lib/src/web/tts.dart Web TTS generation config wiring (incl. reference audio for voice cloning).
flutter/sherpa_onnx/lib/src/web/offline_punctuation.dart Web OfflinePunctuation implementation via JS/WASM interop.
flutter-examples/tts/lib/worker_web.dart Fix asset byte slicing and ArrayBuffer transfer to worker.
flutter-examples/online-punctuation/windows/runner/win32_window.h Windows runner scaffold for the online punctuation example.
flutter-examples/online-punctuation/windows/runner/utils.h Windows runner utilities declarations.
flutter-examples/online-punctuation/windows/runner/utils.cpp Windows runner console/CLI utilities implementation.
flutter-examples/online-punctuation/windows/runner/Runner.rc Windows resources for the online punctuation example.
flutter-examples/online-punctuation/windows/runner/runner.exe.manifest Windows app manifest (DPI awareness, OS compatibility).
flutter-examples/online-punctuation/windows/runner/resource.h Windows resource IDs.
flutter-examples/online-punctuation/windows/runner/main.cpp Windows entrypoint / message loop wiring.
flutter-examples/online-punctuation/windows/runner/flutter_window.h Windows Flutter host window declaration.
flutter-examples/online-punctuation/windows/runner/flutter_window.cpp Windows Flutter host window implementation.
flutter-examples/online-punctuation/windows/runner/CMakeLists.txt Windows runner build rules.
flutter-examples/online-punctuation/windows/flutter/CMakeLists.txt Flutter-managed Windows build rules.
flutter-examples/online-punctuation/windows/CMakeLists.txt Project-level Windows build rules.
flutter-examples/online-punctuation/windows/.gitignore Windows build output ignores.
flutter-examples/online-punctuation/web/manifest.json Web app manifest for the online punctuation example.
flutter-examples/online-punctuation/web/index.html Web bootstrap HTML for the online punctuation example.
flutter-examples/online-punctuation/test/widget_test.dart Widget test scaffold for the online punctuation example.
flutter-examples/online-punctuation/README.md Build/run/model download instructions for the online punctuation example.
flutter-examples/online-punctuation/pubspec.yaml Dependencies and metadata for the online punctuation example.
flutter-examples/online-punctuation/macos/RunnerTests/RunnerTests.swift macOS runner test scaffold.
flutter-examples/online-punctuation/macos/Runner/Release.entitlements macOS release entitlements.
flutter-examples/online-punctuation/macos/Runner/MainFlutterWindow.swift macOS main window wiring.
flutter-examples/online-punctuation/macos/Runner/Info.plist macOS bundle metadata.
flutter-examples/online-punctuation/macos/Runner/DebugProfile.entitlements macOS debug/profile entitlements.
flutter-examples/online-punctuation/macos/Runner/Configs/Warnings.xcconfig macOS warnings config.
flutter-examples/online-punctuation/macos/Runner/Configs/Release.xcconfig macOS release xcconfig include.
flutter-examples/online-punctuation/macos/Runner/Configs/Debug.xcconfig macOS debug xcconfig include.
flutter-examples/online-punctuation/macos/Runner/Configs/AppInfo.xcconfig macOS app name/bundle ID/copyright.
flutter-examples/online-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json macOS icon catalog.
flutter-examples/online-punctuation/macos/Runner/AppDelegate.swift macOS app delegate scaffold.
flutter-examples/online-punctuation/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist macOS workspace checks.
flutter-examples/online-punctuation/macos/Runner.xcworkspace/contents.xcworkspacedata macOS workspace definition.
flutter-examples/online-punctuation/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme macOS scheme.
flutter-examples/online-punctuation/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist macOS project workspace checks.
flutter-examples/online-punctuation/macos/Flutter/Flutter-Release.xcconfig macOS Flutter release include.
flutter-examples/online-punctuation/macos/Flutter/Flutter-Debug.xcconfig macOS Flutter debug include.
flutter-examples/online-punctuation/macos/.gitignore macOS build output ignores.
flutter-examples/online-punctuation/linux/runner/my_application.h Linux runner scaffold header.
flutter-examples/online-punctuation/linux/runner/main.cc Linux runner entrypoint.
flutter-examples/online-punctuation/linux/runner/CMakeLists.txt Linux runner build rules.
flutter-examples/online-punctuation/linux/flutter/CMakeLists.txt Flutter-managed Linux build rules.
flutter-examples/online-punctuation/linux/.gitignore Linux build output ignores.
flutter-examples/online-punctuation/lib/worker_web.dart Web worker controller for online punctuation.
flutter-examples/online-punctuation/lib/worker_stub.dart Non-web worker stub for online punctuation.
flutter-examples/online-punctuation/lib/punct_screen.dart Online punctuation demo screen UI.
flutter-examples/online-punctuation/lib/punct_controls.dart Shared input/result controls UI for punctuation.
flutter-examples/online-punctuation/lib/model.dart Native model asset-to-disk handling for online punctuation.
flutter-examples/online-punctuation/lib/model_web.dart Web model asset loading / config serialization for online punctuation.
flutter-examples/online-punctuation/lib/model_config.dart Online punctuation model selection constants/config.
flutter-examples/online-punctuation/ios/RunnerTests/RunnerTests.swift iOS runner test scaffold.
flutter-examples/online-punctuation/ios/Runner/SceneDelegate.swift iOS scene delegate scaffold.
flutter-examples/online-punctuation/ios/Runner/Runner-Bridging-Header.h iOS bridging header.
flutter-examples/online-punctuation/ios/Runner/Info.plist iOS app metadata.
flutter-examples/online-punctuation/ios/Runner/Base.lproj/Main.storyboard iOS main storyboard scaffold.
flutter-examples/online-punctuation/ios/Runner/Base.lproj/LaunchScreen.storyboard iOS launch screen scaffold.
flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md iOS launch image docs scaffold.
flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json iOS launch image catalog.
flutter-examples/online-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json iOS app icon catalog.
flutter-examples/online-punctuation/ios/Runner/AppDelegate.swift iOS app delegate scaffold.
flutter-examples/online-punctuation/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings iOS workspace settings.
flutter-examples/online-punctuation/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist iOS workspace checks.
flutter-examples/online-punctuation/ios/Runner.xcworkspace/contents.xcworkspacedata iOS workspace definition.
flutter-examples/online-punctuation/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme iOS scheme.
flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings iOS project workspace settings.
flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist iOS project workspace checks.
flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata iOS project workspace definition.
flutter-examples/online-punctuation/ios/Flutter/Release.xcconfig iOS Flutter release include.
flutter-examples/online-punctuation/ios/Flutter/Debug.xcconfig iOS Flutter debug include.
flutter-examples/online-punctuation/ios/Flutter/AppFrameworkInfo.plist iOS Flutter framework plist scaffold.
flutter-examples/online-punctuation/ios/.gitignore iOS build output ignores.
flutter-examples/online-punctuation/assets/.gitkeep Placeholder to keep assets dir in VCS.
flutter-examples/online-punctuation/android/settings.gradle.kts Android Gradle settings for online punctuation example.
flutter-examples/online-punctuation/android/gradle/wrapper/gradle-wrapper.properties Gradle wrapper version for example.
flutter-examples/online-punctuation/android/gradle.properties Android gradle properties for example.
flutter-examples/online-punctuation/android/build.gradle.kts Top-level Android build config for example.
flutter-examples/online-punctuation/android/app/src/profile/AndroidManifest.xml Android profile manifest.
flutter-examples/online-punctuation/android/app/src/main/res/values/styles.xml Android styles (light).
flutter-examples/online-punctuation/android/app/src/main/res/values-night/styles.xml Android styles (dark).
flutter-examples/online-punctuation/android/app/src/main/res/drawable/launch_background.xml Android launch background.
flutter-examples/online-punctuation/android/app/src/main/res/drawable-v21/launch_background.xml Android v21 launch background.
flutter-examples/online-punctuation/android/app/src/main/kotlin/com/example/online_punctuation/MainActivity.kt Android main activity scaffold.
flutter-examples/online-punctuation/android/app/src/main/AndroidManifest.xml Android main manifest.
flutter-examples/online-punctuation/android/app/src/debug/AndroidManifest.xml Android debug manifest.
flutter-examples/online-punctuation/android/app/build.gradle.kts Android app module build config.
flutter-examples/online-punctuation/android/.gitignore Android build output ignores.
flutter-examples/online-punctuation/analysis_options.yaml Analyzer/lints config.
flutter-examples/online-punctuation/.metadata Flutter tool metadata.
flutter-examples/online-punctuation/.gitignore Example-level ignores.
flutter-examples/offline-punctuation/windows/runner/win32_window.h Windows runner scaffold for the offline punctuation example.
flutter-examples/offline-punctuation/windows/runner/utils.h Windows runner utilities declarations.
flutter-examples/offline-punctuation/windows/runner/utils.cpp Windows runner console/CLI utilities implementation.
flutter-examples/offline-punctuation/windows/runner/Runner.rc Windows resources for the offline punctuation example.
flutter-examples/offline-punctuation/windows/runner/runner.exe.manifest Windows app manifest (DPI awareness, OS compatibility).
flutter-examples/offline-punctuation/windows/runner/resource.h Windows resource IDs.
flutter-examples/offline-punctuation/windows/runner/main.cpp Windows entrypoint / message loop wiring.
flutter-examples/offline-punctuation/windows/runner/flutter_window.h Windows Flutter host window declaration.
flutter-examples/offline-punctuation/windows/runner/flutter_window.cpp Windows Flutter host window implementation.
flutter-examples/offline-punctuation/windows/runner/CMakeLists.txt Windows runner build rules.
flutter-examples/offline-punctuation/windows/flutter/CMakeLists.txt Flutter-managed Windows build rules.
flutter-examples/offline-punctuation/windows/CMakeLists.txt Project-level Windows build rules.
flutter-examples/offline-punctuation/windows/.gitignore Windows build output ignores.
flutter-examples/offline-punctuation/web/manifest.json Web app manifest for the offline punctuation example.
flutter-examples/offline-punctuation/web/index.html Web bootstrap HTML for the offline punctuation example.
flutter-examples/offline-punctuation/test/widget_test.dart Widget test scaffold for the offline punctuation example.
flutter-examples/offline-punctuation/README.md Build/run/model download instructions for the offline punctuation example.
flutter-examples/offline-punctuation/pubspec.yaml Dependencies and metadata for the offline punctuation example.
flutter-examples/offline-punctuation/macos/RunnerTests/RunnerTests.swift macOS runner test scaffold.
flutter-examples/offline-punctuation/macos/Runner/Release.entitlements macOS release entitlements.
flutter-examples/offline-punctuation/macos/Runner/MainFlutterWindow.swift macOS main window wiring.
flutter-examples/offline-punctuation/macos/Runner/Info.plist macOS bundle metadata.
flutter-examples/offline-punctuation/macos/Runner/DebugProfile.entitlements macOS debug/profile entitlements.
flutter-examples/offline-punctuation/macos/Runner/Configs/Warnings.xcconfig macOS warnings config.
flutter-examples/offline-punctuation/macos/Runner/Configs/Release.xcconfig macOS release xcconfig include.
flutter-examples/offline-punctuation/macos/Runner/Configs/Debug.xcconfig macOS debug xcconfig include.
flutter-examples/offline-punctuation/macos/Runner/Configs/AppInfo.xcconfig macOS app name/bundle ID/copyright.
flutter-examples/offline-punctuation/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json macOS icon catalog.
flutter-examples/offline-punctuation/macos/Runner/AppDelegate.swift macOS app delegate scaffold.
flutter-examples/offline-punctuation/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist macOS workspace checks.
flutter-examples/offline-punctuation/macos/Runner.xcworkspace/contents.xcworkspacedata macOS workspace definition.
flutter-examples/offline-punctuation/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme macOS scheme.
flutter-examples/offline-punctuation/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist macOS project workspace checks.
flutter-examples/offline-punctuation/macos/Flutter/Flutter-Release.xcconfig macOS Flutter release include.
flutter-examples/offline-punctuation/macos/Flutter/Flutter-Debug.xcconfig macOS Flutter debug include.
flutter-examples/offline-punctuation/macos/.gitignore macOS build output ignores.
flutter-examples/offline-punctuation/linux/runner/my_application.h Linux runner scaffold header.
flutter-examples/offline-punctuation/linux/runner/main.cc Linux runner entrypoint.
flutter-examples/offline-punctuation/linux/runner/CMakeLists.txt Linux runner build rules.
flutter-examples/offline-punctuation/linux/flutter/CMakeLists.txt Flutter-managed Linux build rules.
flutter-examples/offline-punctuation/linux/.gitignore Linux build output ignores.
flutter-examples/offline-punctuation/lib/worker_web.dart Web worker controller for offline punctuation.
flutter-examples/offline-punctuation/lib/worker_stub.dart Non-web worker stub for offline punctuation.
flutter-examples/offline-punctuation/lib/punct_screen.dart Offline punctuation demo screen UI.
flutter-examples/offline-punctuation/lib/punct_controls.dart Shared input/result controls UI for punctuation.
flutter-examples/offline-punctuation/lib/model.dart Native model asset-to-disk handling for offline punctuation.
flutter-examples/offline-punctuation/lib/model_web.dart Web model asset loading / config serialization for offline punctuation.
flutter-examples/offline-punctuation/lib/model_config.dart Offline punctuation model selection constants/config.
flutter-examples/offline-punctuation/ios/RunnerTests/RunnerTests.swift iOS runner test scaffold.
flutter-examples/offline-punctuation/ios/Runner/SceneDelegate.swift iOS scene delegate scaffold.
flutter-examples/offline-punctuation/ios/Runner/Runner-Bridging-Header.h iOS bridging header.
flutter-examples/offline-punctuation/ios/Runner/Info.plist iOS app metadata.
flutter-examples/offline-punctuation/ios/Runner/Base.lproj/Main.storyboard iOS main storyboard scaffold.
flutter-examples/offline-punctuation/ios/Runner/Base.lproj/LaunchScreen.storyboard iOS launch screen scaffold.
flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md iOS launch image docs scaffold.
flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json iOS launch image catalog.
flutter-examples/offline-punctuation/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json iOS app icon catalog.
flutter-examples/offline-punctuation/ios/Runner/AppDelegate.swift iOS app delegate scaffold.
flutter-examples/offline-punctuation/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings iOS workspace settings.
flutter-examples/offline-punctuation/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist iOS workspace checks.
flutter-examples/offline-punctuation/ios/Runner.xcworkspace/contents.xcworkspacedata iOS workspace definition.
flutter-examples/offline-punctuation/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme iOS scheme.
flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings iOS project workspace settings.
flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist iOS project workspace checks.
flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata iOS project workspace definition.
flutter-examples/offline-punctuation/ios/Flutter/Release.xcconfig iOS Flutter release include.
flutter-examples/offline-punctuation/ios/Flutter/Debug.xcconfig iOS Flutter debug include.
flutter-examples/offline-punctuation/ios/Flutter/AppFrameworkInfo.plist iOS Flutter framework plist scaffold.
flutter-examples/offline-punctuation/ios/.gitignore iOS build output ignores.
flutter-examples/offline-punctuation/assets/.gitkeep Placeholder to keep assets dir in VCS.
flutter-examples/offline-punctuation/android/settings.gradle.kts Android Gradle settings for offline punctuation example.
flutter-examples/offline-punctuation/android/gradle/wrapper/gradle-wrapper.properties Gradle wrapper version for example.
flutter-examples/offline-punctuation/android/gradle.properties Android gradle properties for example.
flutter-examples/offline-punctuation/android/build.gradle.kts Top-level Android build config for example.
flutter-examples/offline-punctuation/android/app/src/profile/AndroidManifest.xml Android profile manifest.
flutter-examples/offline-punctuation/android/app/src/main/res/values/styles.xml Android styles (light).
flutter-examples/offline-punctuation/android/app/src/main/res/values-night/styles.xml Android styles (dark).
flutter-examples/offline-punctuation/android/app/src/main/res/drawable/launch_background.xml Android launch background.
flutter-examples/offline-punctuation/android/app/src/main/res/drawable-v21/launch_background.xml Android v21 launch background.
flutter-examples/offline-punctuation/android/app/src/main/kotlin/com/example/offline_punctuation/MainActivity.kt Android main activity scaffold.
flutter-examples/offline-punctuation/android/app/src/main/AndroidManifest.xml Android main manifest.
flutter-examples/offline-punctuation/android/app/src/debug/AndroidManifest.xml Android debug manifest.
flutter-examples/offline-punctuation/android/app/build.gradle.kts Android app module build config.
flutter-examples/offline-punctuation/android/.gitignore Android build output ignores.
flutter-examples/offline-punctuation/analysis_options.yaml Analyzer/lints config.
flutter-examples/offline-punctuation/.metadata Flutter tool metadata.
flutter-examples/offline-punctuation/.gitignore Example-level ignores.
cmake/simple-sentencepiece.cmake WASM build patching to stub out sentencepiece threading.
Files not reviewed (6)
  • flutter-examples/offline-punctuation/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: Generated file
  • flutter-examples/offline-punctuation/ios/Runner.xcworkspace/contents.xcworkspacedata: Generated file
  • flutter-examples/offline-punctuation/macos/Runner.xcworkspace/contents.xcworkspacedata: Generated file
  • flutter-examples/online-punctuation/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: Generated file
  • flutter-examples/online-punctuation/ios/Runner.xcworkspace/contents.xcworkspacedata: Generated file
  • flutter-examples/online-punctuation/macos/Runner.xcworkspace/contents.xcworkspacedata: Generated file

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

Comment on lines +14 to +29
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
Comment on lines +2 to +3
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
Comment on lines +14 to +29
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
Comment on lines +2 to +3
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
Comment on lines +13 to +18
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
_dup2(_fileno(stdout), 2);
}
Comment on lines +13 to +18
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
_dup2(_fileno(stdout), 2);
}
Comment on lines +55 to +74
#include <functional>
#include <future>
#include <memory>
#include <vector>

class ThreadPool {
public:
ThreadPool(size_t) {}
template<class F, class... Args>
std::future<typename std::result_of<F(Args...)>::type>
enqueue(F&& f, Args&&... args) {
// Run synchronously — no threading in WASM.
using return_type = typename std::result_of<F(Args...)>::type;
auto task = std::make_shared<std::packaged_task<return_type()>>(
std::bind(std::forward<F>(f), std::forward<Args>(args)...));
std::future<return_type> res = task->get_future();
(*task)();
return res;
}
};
// Reference audio for voice cloning (e.g. Pocket TTS).
if (config.referenceAudio != null && config.referenceAudio!.isNotEmpty) {
genConfig['referenceAudio'] = config.referenceAudio;
genConfig['referenceAudio'] = config.referenceAudio as JSAny;

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

♻️ Duplicate comments (1)
flutter/sherpa_onnx/lib/src/web/tts.dart (1)

83-88: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve the Float32List view range.

config.referenceAudio!.buffer.toJS exposes the whole backing buffer. A valid Float32List can be a view with an offset or a shorter length, so this can pass unrelated samples to the Web wrapper. Use the list-level Float32List.toJS conversion, or pass the view byte offset and length to Float32Array.

Proposed fix
-      // Convert Float32List to a JS Float32Array via the ArrayBuffer constructor.
-      final arrayBuffer = config.referenceAudio!.buffer.toJS;
-      final float32ArrayCtor =
-          globalContext.getProperty('Float32Array'.toJS) as JSFunction;
-      genConfig['referenceAudio'] =
-          float32ArrayCtor.callAsConstructor(arrayBuffer);
+      genConfig['referenceAudio'] = config.referenceAudio!.toJS;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flutter/sherpa_onnx/lib/src/web/tts.dart` around lines 83 - 88, Update the
reference-audio conversion in the surrounding TTS configuration flow to preserve
the Float32List view’s offset and length: use config.referenceAudio!.toJS
directly, or construct the JavaScript Float32Array with the view’s byte offset
and byte length instead of the entire buffer. Keep the resulting value assigned
to genConfig['referenceAudio'].

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@flutter/sherpa_onnx/lib/src/web/tts.dart`:
- Around line 83-88: Update the reference-audio conversion in the surrounding
TTS configuration flow to preserve the Float32List view’s offset and length: use
config.referenceAudio!.toJS directly, or construct the JavaScript Float32Array
with the view’s byte offset and byte length instead of the entire buffer. Keep
the resulting value assigned to genConfig['referenceAudio'].

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c26ad85-0330-4cb5-912e-6768c587ef7e

📥 Commits

Reviewing files that changed from the base of the PR and between b75258d and d6f733d.

📒 Files selected for processing (5)
  • cmake/simple-sentencepiece.cmake
  • flutter-examples/offline-punctuation/lib/punct_screen.dart
  • flutter-examples/online-punctuation/lib/punct_screen.dart
  • flutter-examples/tts/test/widget_test.dart
  • flutter/sherpa_onnx/lib/src/web/tts.dart
💤 Files with no reviewable changes (3)
  • flutter-examples/tts/test/widget_test.dart
  • flutter-examples/offline-punctuation/lib/punct_screen.dart
  • flutter-examples/online-punctuation/lib/punct_screen.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmake/simple-sentencepiece.cmake

@csukuangfj
csukuangfj merged commit ceec186 into k2-fsa:master Aug 7, 2026
48 of 50 checks passed
@csukuangfj
csukuangfj deleted the flutter-punctuation branch August 7, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants