From 155bb2c34b3a8a33b2698689ccafa0727f409192 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 8 Feb 2024 17:12:43 -0800 Subject: [PATCH] init --- binding/flutter/CHANGELOG.md | 3 ++ binding/flutter/android/build.gradle | 15 +++++- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../flutter/cheetah/CheetahPlugin.java | 4 +- .../ios/Classes/SwiftCheetahPlugin.swift | 4 +- binding/flutter/ios/cheetah_flutter.podspec | 2 +- binding/flutter/lib/cheetah.dart | 27 +++++++--- binding/flutter/pubspec.lock | 50 +++++++++---------- binding/flutter/pubspec.yaml | 4 +- demo/flutter/pubspec.lock | 13 +++-- demo/flutter/pubspec.yaml | 7 +-- 11 files changed, 79 insertions(+), 52 deletions(-) diff --git a/binding/flutter/CHANGELOG.md b/binding/flutter/CHANGELOG.md index fd54b0a4..ff3ab15f 100644 --- a/binding/flutter/CHANGELOG.md +++ b/binding/flutter/CHANGELOG.md @@ -16,3 +16,6 @@ ## [2.0.0] - 2023-11-17 * Engine improvements * Improved error reporting + +## [2.0.1] - 2024-02-08 +* Additional gradle plugin build support \ No newline at end of file diff --git a/binding/flutter/android/build.gradle b/binding/flutter/android/build.gradle index 024f9baa..4968ce06 100644 --- a/binding/flutter/android/build.gradle +++ b/binding/flutter/android/build.gradle @@ -1,5 +1,5 @@ group 'ai.picovoice.flutter.cheetah' -version '2.0.0' +version '2.0.1' buildscript { repositories { @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.3' + classpath 'com.android.tools.build:gradle:7.4.2' } } @@ -22,6 +22,17 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION + if (agpVersion.tokenize('.')[0].toInteger() >= 7) { + namespace "ai.picovoice.flutter.cheetah" + } + + if (agpVersion.tokenize('.')[0].toInteger() >= 8) { + buildFeatures { + buildConfig = true + } + } + compileSdkVersion 31 defaultConfig { diff --git a/binding/flutter/android/gradle/wrapper/gradle-wrapper.properties b/binding/flutter/android/gradle/wrapper/gradle-wrapper.properties index e3372e22..835775ae 100644 --- a/binding/flutter/android/gradle/wrapper/gradle-wrapper.properties +++ b/binding/flutter/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Nov 16 13:19:26 PST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/binding/flutter/android/src/main/java/ai/picovoice/flutter/cheetah/CheetahPlugin.java b/binding/flutter/android/src/main/java/ai/picovoice/flutter/cheetah/CheetahPlugin.java index a76736ed..9678e8bf 100644 --- a/binding/flutter/android/src/main/java/ai/picovoice/flutter/cheetah/CheetahPlugin.java +++ b/binding/flutter/android/src/main/java/ai/picovoice/flutter/cheetah/CheetahPlugin.java @@ -1,5 +1,5 @@ // -// Copyright 2022-2023 Picovoice Inc. +// Copyright 2022-2024 Picovoice Inc. // // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" // file accompanying this source. @@ -50,7 +50,7 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { Method method; try { - method = Method.valueOf(call.method.toUpperCase()); + method = Method.valueOf(call.method); } catch (IllegalArgumentException e) { result.error( CheetahRuntimeException.class.getSimpleName(), diff --git a/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift b/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift index ea2722d3..339c985b 100644 --- a/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift +++ b/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift @@ -1,5 +1,5 @@ // -// Copyright 2022-2023 Picovoice Inc. +// Copyright 2022-2024 Picovoice Inc. // // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" // file accompanying this source. @@ -33,7 +33,7 @@ public class SwiftCheetahPlugin: NSObject, FlutterPlugin { } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - guard let method = Method(rawValue: call.method.uppercased()) else { + guard let method = Method(rawValue: call.method) else { result(errorToFlutterError(CheetahRuntimeError("Cheetah method '\(call.method)' is not a valid function"))) return } diff --git a/binding/flutter/ios/cheetah_flutter.podspec b/binding/flutter/ios/cheetah_flutter.podspec index 36ae5288..cd89b9b7 100644 --- a/binding/flutter/ios/cheetah_flutter.podspec +++ b/binding/flutter/ios/cheetah_flutter.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'cheetah_flutter' - s.version = '2.0.0' + s.version = '2.0.1' s.summary = 'A Flutter package plugin for Picovoice\'s Cheetah Speech-to-Text engine' s.description = <<-DESC A Flutter package plugin for Picovoice\'s Cheetah Speech-to-Text engine diff --git a/binding/flutter/lib/cheetah.dart b/binding/flutter/lib/cheetah.dart index 6e917c90..c90f8362 100644 --- a/binding/flutter/lib/cheetah.dart +++ b/binding/flutter/lib/cheetah.dart @@ -1,5 +1,5 @@ // -// Copyright 2022 Picovoice Inc. +// Copyright 2022-2024 Picovoice Inc. // // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" // file accompanying this source. @@ -16,6 +16,17 @@ import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart'; import 'package:cheetah_flutter/cheetah_error.dart'; +enum _NativeFunctions { + // ignore:constant_identifier_names + CREATE, + // ignore:constant_identifier_names + PROCESS, + // ignore:constant_identifier_names + FLUSH, + // ignore:constant_identifier_names + DELETE +} + class CheetahTranscript { final String? _transcript; final bool? _isEndpoint; @@ -63,8 +74,8 @@ class Cheetah { modelPath = await _tryExtractFlutterAsset(modelPath); try { - Map result = - Map.from(await _channel.invokeMethod('create', { + Map result = Map.from( + await _channel.invokeMethod(_NativeFunctions.CREATE.name, { 'accessKey': accessKey, 'modelPath': modelPath, 'endpointDuration': endpointDuration, @@ -92,7 +103,8 @@ class Cheetah { Future process(List? frame) async { try { Map transcript = Map.from(await _channel - .invokeMethod('process', {'handle': _handle, 'frame': frame})); + .invokeMethod(_NativeFunctions.PROCESS.name, + {'handle': _handle, 'frame': frame})); if (transcript['transcript'] == null) { throw CheetahInvalidStateException( @@ -113,8 +125,8 @@ class Cheetah { /// returns CheetahTranscript object. Future flush() async { try { - Map transcript = Map.from( - await _channel.invokeMethod('flush', {'handle': _handle})); + Map transcript = Map.from(await _channel + .invokeMethod(_NativeFunctions.FLUSH.name, {'handle': _handle})); if (transcript['transcript'] == null) { throw CheetahInvalidStateException( @@ -132,7 +144,8 @@ class Cheetah { /// Frees memory that was allocated for Cheetah Future delete() async { if (_handle != null) { - await _channel.invokeMethod('delete', {'handle': _handle}); + await _channel + .invokeMethod(_NativeFunctions.DELETE.name, {'handle': _handle}); _handle = null; } } diff --git a/binding/flutter/pubspec.lock b/binding/flutter/pubspec.lock index 2514f310..a375c7c7 100644 --- a/binding/flutter/pubspec.lock +++ b/binding/flutter/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.18.0" fake_async: dependency: transitive description: @@ -75,14 +75,6 @@ packages: description: flutter source: sdk version: "0.0.0" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" lints: dependency: "direct dev" description: @@ -95,26 +87,26 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" path: dependency: transitive description: @@ -212,26 +204,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -252,10 +244,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.1" vector_math: dependency: transitive description: @@ -264,6 +256,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" win32: dependency: transitive description: @@ -281,5 +281,5 @@ packages: source: hosted version: "0.2.0" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=2.8.1" diff --git a/binding/flutter/pubspec.yaml b/binding/flutter/pubspec.yaml index ab91a7a6..e0bd25f1 100644 --- a/binding/flutter/pubspec.yaml +++ b/binding/flutter/pubspec.yaml @@ -1,12 +1,12 @@ name: cheetah_flutter description: A Flutter plugin for Picovoice's Cheetah Speech-to-Text engine -version: 2.0.0 +version: 2.0.1 homepage: https://picovoice.ai/ repository: https://github.com/Picovoice/cheetah/ documentation: https://picovoice.ai/docs/cheetah/ environment: - sdk: ">=2.14.0 <3.0.0" + sdk: ">=2.15.0 <4.0.0" flutter: ">=2.8.1" dependencies: diff --git a/demo/flutter/pubspec.lock b/demo/flutter/pubspec.lock index d3060e73..b70da541 100644 --- a/demo/flutter/pubspec.lock +++ b/demo/flutter/pubspec.lock @@ -28,11 +28,10 @@ packages: cheetah_flutter: dependency: "direct main" description: - name: cheetah_flutter - sha256: c1283f35cc175f589b5e77dec23e8f6f85477e26bf7b194b7d468387a20ddb3f - url: "https://pub.dev" - source: hosted - version: "2.0.0" + path: "../../binding/flutter" + relative: true + source: path + version: "2.0.1" clock: dependency: transitive description: @@ -92,10 +91,10 @@ packages: dependency: "direct main" description: name: flutter_voice_processor - sha256: fb511a2f0ca9540c4b7c6715515389d27b5bbd332138ab3a300078fb243a0caf + sha256: "3c91d8ab34b33016643ae7586a305b81c47c1b66a95b489807c34f127537fcbc" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" fuchsia_remote_debug_protocol: dependency: transitive description: flutter diff --git a/demo/flutter/pubspec.yaml b/demo/flutter/pubspec.yaml index b1d27705..1f5397fc 100644 --- a/demo/flutter/pubspec.yaml +++ b/demo/flutter/pubspec.yaml @@ -6,15 +6,16 @@ publish_to: 'none' version: 2.0.0 environment: - sdk: ">=2.14.0 <3.0.0" + sdk: ">=2.15.0 <4.0.0" flutter: ">=2.8.1" dependencies: flutter: sdk: flutter - flutter_voice_processor: ^1.1.0 - cheetah_flutter: ^2.0.0 + flutter_voice_processor: ^1.1.1 + cheetah_flutter: + path: ../../binding/flutter dev_dependencies: integration_test: