Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
laves committed Feb 9, 2024
1 parent 42b2546 commit 155bb2c
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 52 deletions.
3 changes: 3 additions & 0 deletions binding/flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 13 additions & 2 deletions binding/flutter/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'ai.picovoice.flutter.cheetah'
version '2.0.0'
version '2.0.1'

buildscript {
repositories {
Expand All @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions binding/flutter/ios/Classes/SwiftCheetahPlugin.swift
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion binding/flutter/ios/cheetah_flutter.podspec
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 20 additions & 7 deletions binding/flutter/lib/cheetah.dart
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -63,8 +74,8 @@ class Cheetah {
modelPath = await _tryExtractFlutterAsset(modelPath);

try {
Map<String, dynamic> result =
Map<String, dynamic>.from(await _channel.invokeMethod('create', {
Map<String, dynamic> result = Map<String, dynamic>.from(
await _channel.invokeMethod(_NativeFunctions.CREATE.name, {
'accessKey': accessKey,
'modelPath': modelPath,
'endpointDuration': endpointDuration,
Expand Down Expand Up @@ -92,7 +103,8 @@ class Cheetah {
Future<CheetahTranscript> process(List<int>? frame) async {
try {
Map<String, dynamic> transcript = Map<String, dynamic>.from(await _channel
.invokeMethod('process', {'handle': _handle, 'frame': frame}));
.invokeMethod(_NativeFunctions.PROCESS.name,
{'handle': _handle, 'frame': frame}));

if (transcript['transcript'] == null) {
throw CheetahInvalidStateException(
Expand All @@ -113,8 +125,8 @@ class Cheetah {
/// returns CheetahTranscript object.
Future<CheetahTranscript> flush() async {
try {
Map<String, dynamic> transcript = Map<String, dynamic>.from(
await _channel.invokeMethod('flush', {'handle': _handle}));
Map<String, dynamic> transcript = Map<String, dynamic>.from(await _channel
.invokeMethod(_NativeFunctions.FLUSH.name, {'handle': _handle}));

if (transcript['transcript'] == null) {
throw CheetahInvalidStateException(
Expand All @@ -132,7 +144,8 @@ class Cheetah {
/// Frees memory that was allocated for Cheetah
Future<void> delete() async {
if (_handle != null) {
await _channel.invokeMethod('delete', {'handle': _handle});
await _channel
.invokeMethod(_NativeFunctions.DELETE.name, {'handle': _handle});
_handle = null;
}
}
Expand Down
50 changes: 25 additions & 25 deletions binding/flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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"
4 changes: 2 additions & 2 deletions binding/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
13 changes: 6 additions & 7 deletions demo/flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions demo/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 155bb2c

Please sign in to comment.