Refactor flutter to support Android (#1072)
This commit is contained in:
29
flutter/sherpa_onnx_android/.gitignore
vendored
Normal file
29
flutter/sherpa_onnx_android/.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||
/pubspec.lock
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
build/
|
||||
30
flutter/sherpa_onnx_android/.metadata
Normal file
30
flutter/sherpa_onnx_android/.metadata
Normal file
@@ -0,0 +1,30 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "5dcb86f68f239346676ceb1ed1ea385bd215fba1"
|
||||
channel: "stable"
|
||||
|
||||
project_type: plugin_ffi
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
|
||||
base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
|
||||
- platform: android
|
||||
create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
|
||||
base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||
7
flutter/sherpa_onnx_android/README.md
Normal file
7
flutter/sherpa_onnx_android/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# sherpa_onnx_android
|
||||
|
||||
This is a sub project of [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx).
|
||||
|
||||
You are not expected to use this package directly.
|
||||
|
||||
Please see the entry point at <https://pub.dev/packages/sherpa_onnx>.
|
||||
4
flutter/sherpa_onnx_android/analysis_options.yaml
Normal file
4
flutter/sherpa_onnx_android/analysis_options.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
9
flutter/sherpa_onnx_android/android/.gitignore
vendored
Normal file
9
flutter/sherpa_onnx_android/android/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.cxx
|
||||
48
flutter/sherpa_onnx_android/android/build.gradle
Normal file
48
flutter/sherpa_onnx_android/android/build.gradle
Normal file
@@ -0,0 +1,48 @@
|
||||
// The Android Gradle Plugin builds the native code with the Android NDK.
|
||||
|
||||
group = "com.k2fsa.sherpa.onnx.sherpa_onnx_android"
|
||||
version = "1.0"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// The Android Gradle Plugin knows how to build native code with the NDK.
|
||||
classpath("com.android.tools.build:gradle:7.3.0")
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "com.android.library"
|
||||
|
||||
android {
|
||||
namespace 'com.k2fsa.sherpa.onnx'
|
||||
|
||||
// Bumping the plugin compileSdk version requires all clients of this plugin
|
||||
// to bump the version in their app.
|
||||
compileSdk = 34
|
||||
|
||||
// Use the NDK version
|
||||
// declared in /android/app/build.gradle file of the Flutter project.
|
||||
// Replace it with a version number if this plugin requires a specific NDK version.
|
||||
// (e.g. ndkVersion "23.1.7779620")
|
||||
ndkVersion = android.ndkVersion
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 21
|
||||
}
|
||||
}
|
||||
1
flutter/sherpa_onnx_android/android/settings.gradle
Normal file
1
flutter/sherpa_onnx_android/android/settings.gradle
Normal file
@@ -0,0 +1 @@
|
||||
rootProject.name = 'sherpa_onnx_android'
|
||||
@@ -0,0 +1,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.k2fsa.sherpa.onnx">
|
||||
</manifest>
|
||||
@@ -0,0 +1,23 @@
|
||||
# Introduction
|
||||
|
||||
Pre-built libs are not checked-in.
|
||||
|
||||
Please use
|
||||
|
||||
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-arm64-v8a.sh
|
||||
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-armv7-eabi.sh
|
||||
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-x86-64.sh
|
||||
- https://github.com/k2-fsa/sherpa-onnx/blob/master/build-android-x86.sh
|
||||
|
||||
The following is an example for `arm64-v8a`:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/k2-fsa/sherpa-onnx
|
||||
cd sherpa-onnx
|
||||
|
||||
export SHERPA_ONNX_ENABLE_JNI=OFF
|
||||
export SHERPA_ONNX_ENABLE_C_API=ON
|
||||
./build-android-arm64-v8a.sh
|
||||
|
||||
cp -v build-android-arm64-v8a/install/lib/*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/arm64-v8a/
|
||||
```
|
||||
43
flutter/sherpa_onnx_android/example/.gitignore
vendored
Normal file
43
flutter/sherpa_onnx_android/example/.gitignore
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
|
||||
# Android Studio will place build artifacts here
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
9
flutter/sherpa_onnx_android/example/README.md
Normal file
9
flutter/sherpa_onnx_android/example/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Introduction
|
||||
|
||||
Please find examples at
|
||||
|
||||
https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter-examples
|
||||
|
||||
and
|
||||
|
||||
https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples
|
||||
18
flutter/sherpa_onnx_android/example/example.md
Normal file
18
flutter/sherpa_onnx_android/example/example.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# sherpa-onnx app example
|
||||
|
||||
## Streaming speech recognition
|
||||
|
||||
Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr
|
||||
|
||||
## Non-streaming speech recognition
|
||||
|
||||
Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr
|
||||
|
||||
## Text to speech (TTS)
|
||||
|
||||
Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts
|
||||
|
||||
## Voice activity detection (VAD)
|
||||
|
||||
Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad
|
||||
|
||||
0
flutter/sherpa_onnx_android/lib/.gitkeep
Normal file
0
flutter/sherpa_onnx_android/lib/.gitkeep
Normal file
18
flutter/sherpa_onnx_android/pubspec.yaml
Normal file
18
flutter/sherpa_onnx_android/pubspec.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
name: sherpa_onnx_android
|
||||
description: "A new Flutter FFI plugin project."
|
||||
version: 0.0.1
|
||||
homepage:
|
||||
|
||||
environment:
|
||||
sdk: '>=3.4.0 <4.0.0'
|
||||
flutter: '>=3.3.0'
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
flutter:
|
||||
plugin:
|
||||
platforms:
|
||||
android:
|
||||
ffiPlugin: true
|
||||
Reference in New Issue
Block a user