From c39ef3b9ccab19701c64cc197a3b9dfc2c54a614 Mon Sep 17 00:00:00 2001 From: Ian Lavery Date: Thu, 23 Nov 2023 15:59:49 -0800 Subject: [PATCH] v2.0 flutter (#267) --- binding/flutter/CHANGELOG.md | 6 +++++- binding/flutter/README.md | 2 +- binding/flutter/android/build.gradle | 10 ++++++++-- .../picovoice/flutter/cheetah/CheetahPlugin.java | 2 ++ .../flutter/ios/Classes/SwiftCheetahPlugin.swift | 4 +++- binding/flutter/ios/cheetah_flutter.podspec | 6 +++--- binding/flutter/pubspec.yaml | 2 +- demo/flutter/android/app/build.gradle | 4 ++-- demo/flutter/android/build.gradle | 6 ++++++ demo/flutter/ios/Podfile | 3 ++- demo/flutter/ios/Podfile.lock | 16 +++++++++------- .../flutter/ios/Runner.xcodeproj/project.pbxproj | 6 +++--- demo/flutter/lib/main.dart | 3 --- demo/flutter/pubspec.lock | 8 ++++---- demo/flutter/pubspec.yaml | 5 +++-- 15 files changed, 52 insertions(+), 31 deletions(-) diff --git a/binding/flutter/CHANGELOG.md b/binding/flutter/CHANGELOG.md index 80916efc..fd54b0a4 100644 --- a/binding/flutter/CHANGELOG.md +++ b/binding/flutter/CHANGELOG.md @@ -11,4 +11,8 @@ * True-casing and automatic punctuation insertion enabled ## [1.1.1] - 2023-08-24 -* Native packages updated \ No newline at end of file +* Native packages updated + +## [2.0.0] - 2023-11-17 +* Engine improvements +* Improved error reporting diff --git a/binding/flutter/README.md b/binding/flutter/README.md index f91241bf..2b99d847 100644 --- a/binding/flutter/README.md +++ b/binding/flutter/README.md @@ -20,7 +20,7 @@ Cheetah is an on-device speech-to-text engine. Cheetah is: This binding is for running Cheetah on **Flutter 2.8.1+** on the following platforms: - Android 5.0+ (API 21+) -- iOS 9.0+ +- iOS 13.0+ ## Installation diff --git a/binding/flutter/android/build.gradle b/binding/flutter/android/build.gradle index 634c6cb8..bdf6fcf1 100644 --- a/binding/flutter/android/build.gradle +++ b/binding/flutter/android/build.gradle @@ -1,10 +1,13 @@ group 'ai.picovoice.flutter.cheetah' -version '1.1.1' +version '2.0.0' buildscript { repositories { google() mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } dependencies { @@ -16,6 +19,9 @@ rootProject.allprojects { repositories { google() mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } } @@ -33,5 +39,5 @@ android { } dependencies { - implementation 'ai.picovoice:cheetah-android:1.1.2' + implementation 'ai.picovoice:cheetah-android:2.0.0' } 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 5b8afcf1..a76736ed 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 @@ -42,6 +42,8 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin flutterContext = flutterPluginBinding.getApplicationContext(); channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "cheetah"); channel.setMethodCallHandler(this); + + Cheetah.setSdk("flutter"); } @Override diff --git a/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift b/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift index b772c6e0..ea2722d3 100644 --- a/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift +++ b/binding/flutter/ios/Classes/SwiftCheetahPlugin.swift @@ -1,5 +1,5 @@ // -// Copyright 2022 Picovoice Inc. +// Copyright 2022-2023 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. @@ -28,6 +28,8 @@ public class SwiftCheetahPlugin: NSObject, FlutterPlugin { let methodChannel = FlutterMethodChannel(name: "cheetah", binaryMessenger: registrar.messenger()) registrar.addMethodCallDelegate(instance, channel: methodChannel) + + Cheetah.setSdk(sdk: "flutter") } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { diff --git a/binding/flutter/ios/cheetah_flutter.podspec b/binding/flutter/ios/cheetah_flutter.podspec index af49080f..36ae5288 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 = '1.1.1' + s.version = '2.0.0' 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 @@ -10,9 +10,9 @@ Pod::Spec.new do |s| s.author = { 'Picovoice' => 'hello@picovoice.ai' } s.source = { :git => "https://github.com/Picovoice/cheetah.git" } s.source_files = 'Classes/**/*' - s.platform = :ios, '9.0' + s.platform = :ios, '13.0' s.dependency 'Flutter' - s.dependency 'Cheetah-iOS', '~> 1.1.0' + s.dependency 'Cheetah-iOS', '~> 2.0.0' s.swift_version = '5.0' end diff --git a/binding/flutter/pubspec.yaml b/binding/flutter/pubspec.yaml index 79d117ff..ab91a7a6 100644 --- a/binding/flutter/pubspec.yaml +++ b/binding/flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: cheetah_flutter description: A Flutter plugin for Picovoice's Cheetah Speech-to-Text engine -version: 1.1.1 +version: 2.0.0 homepage: https://picovoice.ai/ repository: https://github.com/Picovoice/cheetah/ documentation: https://picovoice.ai/docs/cheetah/ diff --git a/demo/flutter/android/app/build.gradle b/demo/flutter/android/app/build.gradle index 7aaa4411..bf4baa26 100644 --- a/demo/flutter/android/app/build.gradle +++ b/demo/flutter/android/app/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 31 + compileSdkVersion 33 lintOptions { disable 'InvalidPackage' @@ -35,7 +35,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "ai.picovoice.flutter.cheetahdemo" minSdkVersion 21 - targetSdkVersion 31 + targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/demo/flutter/android/build.gradle b/demo/flutter/android/build.gradle index fab3c2e1..f94c1a37 100644 --- a/demo/flutter/android/build.gradle +++ b/demo/flutter/android/build.gradle @@ -2,6 +2,9 @@ buildscript { repositories { google() jcenter() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } dependencies { @@ -13,6 +16,9 @@ allprojects { repositories { google() jcenter() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } } diff --git a/demo/flutter/ios/Podfile b/demo/flutter/ios/Podfile index 313ea4a1..bd6db4a5 100644 --- a/demo/flutter/ios/Podfile +++ b/demo/flutter/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '11.0' +platform :ios, '13.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -28,6 +28,7 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe flutter_ios_podfile_setup target 'Runner' do + pod 'Cheetah-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/cheetah/v2.0-ios/binding/ios/Cheetah-iOS.podspec' use_frameworks! use_modular_headers! diff --git a/demo/flutter/ios/Podfile.lock b/demo/flutter/ios/Podfile.lock index edc294e0..da05edc0 100644 --- a/demo/flutter/ios/Podfile.lock +++ b/demo/flutter/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - Cheetah-iOS (1.1.0) - - cheetah_flutter (1.1.1): - - Cheetah-iOS (~> 1.1.0) + - Cheetah-iOS (2.0.0) + - cheetah_flutter (2.0.0): + - Cheetah-iOS (~> 2.0.0) - Flutter - Flutter (1.0.0) - flutter_voice_processor (1.1.0): @@ -14,6 +14,7 @@ PODS: - Flutter DEPENDENCIES: + - Cheetah-iOS (from `https://raw.githubusercontent.com/Picovoice/cheetah/v2.0-ios/binding/ios/Cheetah-iOS.podspec`) - cheetah_flutter (from `.symlinks/plugins/cheetah_flutter/ios`) - Flutter (from `Flutter`) - flutter_voice_processor (from `.symlinks/plugins/flutter_voice_processor/ios`) @@ -22,10 +23,11 @@ DEPENDENCIES: SPEC REPOS: trunk: - - Cheetah-iOS - ios-voice-processor EXTERNAL SOURCES: + Cheetah-iOS: + :podspec: https://raw.githubusercontent.com/Picovoice/cheetah/v2.0-ios/binding/ios/Cheetah-iOS.podspec cheetah_flutter: :path: ".symlinks/plugins/cheetah_flutter/ios" Flutter: @@ -38,14 +40,14 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/path_provider_ios/ios" SPEC CHECKSUMS: - Cheetah-iOS: 6fb7be693878f5b1dec0ea5b6534fbba30954afc - cheetah_flutter: 1733299241a5babdc9ed3d0f3fdd4c14991e30cf + Cheetah-iOS: d98a5edcbf3b74dda6027aeac6a8c0f5997a47a2 + cheetah_flutter: 3f7be021953be4901655a0f4d9741bf8ac5f3413 Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a flutter_voice_processor: 53afbf59ad3feb82f4a379fea9ed8dc98495210f integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1 path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5 -PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d +PODFILE CHECKSUM: effbeff7b91bb3bd110090e42f80abf8a0c41c57 COCOAPODS: 1.11.3 diff --git a/demo/flutter/ios/Runner.xcodeproj/project.pbxproj b/demo/flutter/ios/Runner.xcodeproj/project.pbxproj index c9ca4ee8..c39069fa 100644 --- a/demo/flutter/ios/Runner.xcodeproj/project.pbxproj +++ b/demo/flutter/ios/Runner.xcodeproj/project.pbxproj @@ -339,7 +339,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; STRIP_STYLE = "non-global"; @@ -429,7 +429,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -479,7 +479,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; STRIP_STYLE = "non-global"; diff --git a/demo/flutter/lib/main.dart b/demo/flutter/lib/main.dart index 4c6b25bd..2b49b2a3 100644 --- a/demo/flutter/lib/main.dart +++ b/demo/flutter/lib/main.dart @@ -61,9 +61,6 @@ class _MyAppState extends State { try { _cheetahManager = await CheetahManager.create( accessKey, modelPath, transcriptCallback, errorCallback); - } on CheetahInvalidArgumentException catch (ex) { - errorCallback(CheetahInvalidArgumentException( - "${ex.message}\nEnsure your accessKey '$accessKey' is a valid access key.")); } on CheetahActivationException { errorCallback(CheetahActivationException("AccessKey activation error.")); } on CheetahActivationLimitException { diff --git a/demo/flutter/pubspec.lock b/demo/flutter/pubspec.lock index 3fe8db24..0d38ba3c 100644 --- a/demo/flutter/pubspec.lock +++ b/demo/flutter/pubspec.lock @@ -39,10 +39,10 @@ packages: cheetah_flutter: dependency: "direct main" description: - name: cheetah_flutter - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" + path: "../../binding/flutter" + relative: true + source: path + version: "2.0.0" clock: dependency: transitive description: diff --git a/demo/flutter/pubspec.yaml b/demo/flutter/pubspec.yaml index c698f346..5b908198 100644 --- a/demo/flutter/pubspec.yaml +++ b/demo/flutter/pubspec.yaml @@ -3,7 +3,7 @@ description: Demonstrates how to use the cheetah plugin. publish_to: 'none' -version: 1.0.0 +version: 2.0.0 environment: sdk: ">=2.14.0 <3.0.0" @@ -14,7 +14,8 @@ dependencies: sdk: flutter flutter_voice_processor: ^1.1.0 - cheetah_flutter: ^1.1.1 + cheetah_flutter: + path: ../../binding/flutter dev_dependencies: integration_test: