diff --git a/README.md b/README.md index 71cceb4416..26910d80a1 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,23 @@ with the following APIs ### Links for pre-built Flutter APPs -| Description | URL | 中国用户 | -|--------------------------------|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------| -| Streaming speech recognition | [Address](https://k2-fsa.github.io/sherpa/onnx/flutter/asr/app.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/flutter/asr/app-cn.html) | +#### Real-time speech recognition + +| Description | URL | 中国用户 | +|--------------------------------|---------------------------------------------------------------------|---------------------------------------------------------------------| +| Streaming speech recognition | [Address](https://k2-fsa.github.io/sherpa/onnx/flutter/asr/app.html)| [点此](https://k2-fsa.github.io/sherpa/onnx/flutter/asr/app-cn.html)| + +#### Text-to-speech + +| Description | URL | 中国用户 | +|--------------------------------|--------------------------------------------------------------|-----------------------------------------------------------------------------| +| Android (arm64-v8a, armeabi-v7a, x86_64) | [Address](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-android.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-android-cn.html)| +| Linux (x64) | [Address](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-linux.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-linux-cn.html) | +| macOS (x64) | [Address](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-macos-x64.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-macos-x64-cn.html) | +| macOS (arm64) | [Address](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-macos-arm64.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-macos-arm64-cn.html)| +| Windows (x64) | [Address](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-win.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/flutter/tts-win-cn.html) | + +> Note: You need to build from source for iOS. ### Links for pre-trained models diff --git a/flutter-examples/tts/README.md b/flutter-examples/tts/README.md index 646dcbd696..580c184527 100644 --- a/flutter-examples/tts/README.md +++ b/flutter-examples/tts/README.md @@ -10,6 +10,12 @@ It works on the following platforms: - macOS (both arm64 and x86_64 are supported) - Windows +Screenshots are given below: + +|Android|iOS|Linux|macOS|Windows| +|-------|---|-----|-----|-------| +|![](./android.jpg)|![](./ios.jpg)|![](./ubuntu.jpg)|![](./macos.jpg)|![](./windows.jpg)| + ## How to build Before you run `flutter build`, you have to select a TTS model and change @@ -108,8 +114,75 @@ flutter build apk --split-per-abi - 5. For iOS +First, connect your iPhone to your computer and use `flutter devices` to show +available devices. You will see something like below: + +``` +Found 3 connected devices: + iPhone (mobile) • 00008030-001064212E85802E • ios • iOS 16.3 20D47 + macOS (desktop) • macos • darwin-x64 • macOS 13.1 22C65 darwin-x64 + Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127 + +No wireless devices were found. + +Run "flutter emulators" to list and start any available device emulators. + +If you expected another device to be detected, please run "flutter doctor" to diagnose potential issues. You may also try increasing the time to wait for connected devices with the "--device-timeout" flag. Visit https://flutter.dev/setup/ for troubleshooting tips. +``` + +Then you can use +``` +flutter run -d 00008030-001064212E85802E --release +``` + +You would see something like below: +``` +Launching lib/main.dart on iPhone in release mode... +Automatically signing iOS for device deployment using specified development team in Xcode project: N5ZH3Z63A6 +Running pod install... 1,773ms +Running Xcode build... +Xcode build done. 7.9s +Failed to build iOS app +Could not build the precompiled application for the device. +Error (Xcode): No profiles for 'com.k2fsa.sherpa.onnx.tts' were found: Xcode couldn't find any iOS App Development provisioning profiles matching +'com.k2fsa.sherpa.onnx.tts'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass +-allowProvisioningUpdates to xcodebuild. +/Users/fangjun/open-source/sherpa-onnx/flutter-examples/tts/ios/Runner.xcodeproj + + + +It appears that there was a problem signing your application prior to installation on the device. + +Verify that the Bundle Identifier in your project is your signing id in Xcode + open ios/Runner.xcworkspace + +Also try selecting 'Product > Build' to fix the problem. + +Error running application on iPhone. +``` + +After you have followed the instructions in the above log, run gain + +> Note: I have run `open ios/Runner.xcworkspace` and click `Product -> Build`. + +``` +flutter run -d 00008030-001064212E85802E --release +``` + +Finally, it will show something like below: + ``` -flutter build ios +Launching lib/main.dart on iPhone in release mode... +Automatically signing iOS for device deployment using specified development team in Xcode project: N5ZH3Z63A6 +Running Xcode build... + └─Compiling, linking and signing... 6.5s +Xcode build done. 18.3s +Installing and launching... 22.9s + +Flutter run key commands. +h List all available interactive commands. +c Clear the screen +q Quit (terminate the application on the device). ``` ## Fix for Linux diff --git a/flutter-examples/tts/android.jpg b/flutter-examples/tts/android.jpg new file mode 100644 index 0000000000..cd3f928e9d Binary files /dev/null and b/flutter-examples/tts/android.jpg differ diff --git a/flutter-examples/tts/ios.jpg b/flutter-examples/tts/ios.jpg new file mode 100644 index 0000000000..6e28af4f26 Binary files /dev/null and b/flutter-examples/tts/ios.jpg differ diff --git a/flutter-examples/tts/ios/Runner.xcodeproj/project.pbxproj b/flutter-examples/tts/ios/Runner.xcodeproj/project.pbxproj index 5dc006de82..6e333fd475 100644 --- a/flutter-examples/tts/ios/Runner.xcodeproj/project.pbxproj +++ b/flutter-examples/tts/ios/Runner.xcodeproj/project.pbxproj @@ -373,6 +373,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; + OTHER_LDFLAGS = "-lc++"; VERSIONING_SYSTEM = "apple-generic"; }; name = Profile; @@ -390,6 +391,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; + OTHER_LDFLAGS = "-lc++"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; }; name = Debug; @@ -405,6 +407,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.k2fsa.sherpa.onnx.tts.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; + OTHER_LDFLAGS = "-lc++"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; }; name = Release; @@ -420,6 +423,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.k2fsa.sherpa.onnx.tts.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; + OTHER_LDFLAGS = "-lc++"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; }; name = Profile; @@ -554,6 +558,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; + OTHER_LDFLAGS = "-lc++"; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -576,6 +581,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; + OTHER_LDFLAGS = "-lc++"; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; diff --git a/flutter-examples/tts/lib/model.dart b/flutter-examples/tts/lib/model.dart index facf35cd42..3e519a58a5 100644 --- a/flutter-examples/tts/lib/model.dart +++ b/flutter-examples/tts/lib/model.dart @@ -91,7 +91,7 @@ Future createOfflineTts() async { final all = ruleFsts.split(','); var tmp = []; for (final f in all) { - tmp.add(p.join(directory.path, modelDir, f)); + tmp.add(p.join(directory.path, f)); } ruleFsts = tmp.join(','); } @@ -106,7 +106,7 @@ Future createOfflineTts() async { } if (lexicon != '') { - lexicon = p.join(directory.path, lexicon); + lexicon = p.join(directory.path, modelDir, lexicon); } if (dataDir != '') { diff --git a/flutter-examples/tts/lib/tts.dart b/flutter-examples/tts/lib/tts.dart index 4b28296518..342bf070b4 100644 --- a/flutter-examples/tts/lib/tts.dart +++ b/flutter-examples/tts/lib/tts.dart @@ -37,6 +37,7 @@ class _TtsScreenState extends State { _controller_text_input = TextEditingController(); _controller_hint = TextEditingController(); _controller_sid = TextEditingController(text: '0'); + super.initState(); } @@ -73,6 +74,9 @@ class _TtsScreenState extends State { keyboardType: TextInputType.number, maxLines: 1, controller: _controller_sid, + onTapOutside: (PointerDownEvent event) { + FocusManager.instance.primaryFocus?.unfocus(); + }, inputFormatters: [ FilteringTextInputFormatter.digitsOnly ]), @@ -99,6 +103,9 @@ class _TtsScreenState extends State { ), maxLines: 5, controller: _controller_text_input, + onTapOutside: (PointerDownEvent event) { + FocusManager.instance.primaryFocus?.unfocus(); + }, ), const SizedBox(height: 5), Row( diff --git a/flutter-examples/tts/macos.jpg b/flutter-examples/tts/macos.jpg new file mode 100644 index 0000000000..68d4b77b49 Binary files /dev/null and b/flutter-examples/tts/macos.jpg differ diff --git a/flutter-examples/tts/ubuntu.jpg b/flutter-examples/tts/ubuntu.jpg new file mode 100644 index 0000000000..5e4dcaa981 Binary files /dev/null and b/flutter-examples/tts/ubuntu.jpg differ diff --git a/flutter-examples/tts/windows.jpg b/flutter-examples/tts/windows.jpg new file mode 100644 index 0000000000..45d45f9c20 Binary files /dev/null and b/flutter-examples/tts/windows.jpg differ