Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0 rn #266

Merged
merged 7 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/react-native-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ jobs:
- name: Pre-build dependencies
run: npm install yarn

# ************ REMOVE AFTER RELEASE *****************
- name: Build and package binding
working-directory: binding/react-native
run: yarn && yarn pkg

- name: Add to demo
run: yarn add ../../binding/react-native/pkg/picovoice-cheetah-react-native-2.0.0.tgz
# ***************************************************

- name: Install dependencies
run: yarn android-install

Expand Down Expand Up @@ -66,6 +75,15 @@ jobs:
- name: Pre-build dependencies
run: npm install yarn

# ************ REMOVE AFTER RELEASE *****************
- name: Build and package binding
working-directory: binding/react-native
run: yarn && yarn pkg

- name: Add to demo
run: yarn add ../../binding/react-native/pkg/picovoice-cheetah-react-native-2.0.0.tgz
# ***************************************************

- name: Install dependencies
run: yarn ios-install

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/react-native-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
./copy_test_resources.sh
- name: Cocoapods install
working-directory: binding/react-native/test-app/CheetahTestApp/ios
run: pod install
run: pod install --repo-update

- name: Inject AppID
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:' Tests.ts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/react-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -44,4 +44,4 @@ jobs:
run: yarn install

- name: Build
run: yarn
run: yarn prepare
10 changes: 2 additions & 8 deletions binding/ios/CheetahAppTest/CheetahAppTest/ViewController.swift
Original file line number Diff line number Diff line change
@@ -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.
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
Expand All @@ -9,10 +9,4 @@

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

}
class ViewController: UIViewController { }
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class CheetahDemoUITests: XCTestCase {

let modelURL = Bundle(for: CheetahDemoUITests.self).url(forResource: "cheetah_params", withExtension: "pv")!

override func setUp() {
super.setUp()
}

override func tearDown() {
super.tearDown()
}

override func setUpWithError() throws {
continueAfterFailure = true
}
Expand Down
5 changes: 4 additions & 1 deletion binding/react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ android {
repositories {
mavenCentral()
google()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}

def found = false
def defaultDir = null
Expand Down Expand Up @@ -118,5 +121,5 @@ repositories {
dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation 'ai.picovoice:cheetah-android:1.1.2'
implementation 'ai.picovoice:cheetah-android:2.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
* CheetahModule Class.
*/
public class CheetahModule extends ReactContextBaseJavaModule {

private final ReactApplicationContext reactContext;
private final Map<String, Cheetah> cheetahPool = new HashMap<>();

public CheetahModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;

Cheetah.setSdk("react-native");
}

@NonNull
Expand Down
4 changes: 2 additions & 2 deletions binding/react-native/cheetah-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Pod::Spec.new do |s|
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => "11.0" }
s.platforms = { :ios => "13.0" }
s.source = { :git => "https://github.com/Picovoice/cheetah.git", :tag => "#{s.version}" }

s.source_files = "ios/*.{h,m,mm,swift}"

s.dependency "React"
s.dependency "Cheetah-iOS", '~> 1.1.0'
s.dependency "Cheetah-iOS", '~> 2.0.0'
end
7 changes: 6 additions & 1 deletion binding/react-native/ios/Cheetah.swift
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,6 +15,11 @@ import Cheetah
class PvCheetah: NSObject {
private var cheetahPool: [String: Cheetah] = [:]

override init() {
super.init()
Cheetah.setSdk(sdk: "react-native")
}

@objc(create:modelPath:endpointDuration:enableAutomaticPunctuation:resolver:rejecter:)
func create(
accessKey: String,
Expand Down
2 changes: 1 addition & 1 deletion binding/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@picovoice/cheetah-react-native",
"version": "1.1.1",
"version": "2.0.0",
"description": "Picovoice Cheetah React Native binding",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
1 change: 0 additions & 1 deletion binding/react-native/test-app/CheetahTestApp/.ruby-version

This file was deleted.

6 changes: 0 additions & 6 deletions binding/react-native/test-app/CheetahTestApp/Gemfile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ buildscript {
repositories {
google()
mavenCentral()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
Expand All @@ -36,6 +39,9 @@ allprojects {

allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
maven {
url("$rootDir/../node_modules/detox/Detox-android")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
"$(inherited)",
);
INFOPLIST_FILE = CheetahTestAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -466,7 +466,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
INFOPLIST_FILE = CheetahTestAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -584,7 +584,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand Down Expand Up @@ -649,7 +649,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand Down
3 changes: 2 additions & 1 deletion binding/react-native/test-app/CheetahTestApp/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, min_ios_version_supported
platform :ios, '13.0'
prepare_react_native_project!

flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
Expand All @@ -14,6 +14,7 @@ end

target 'CheetahTestApp' do
config = use_native_modules!
pod 'Cheetah-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/cheetah/v2.0-ios/binding/ios/Cheetah-iOS.podspec'

# Flags change depending on the env values.
flags = get_default_flags()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 29 23:02:09 PDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion demo/react-native/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
handleError(err: any) {
let errorMessage: string;
if (err instanceof CheetahErrors.CheetahInvalidArgumentError) {
errorMessage = `${err.message}\nPlease make sure accessKey ${this._accessKey} is a valid access key.`;
errorMessage = `${err.message}`;
} else if (err instanceof CheetahErrors.CheetahActivationError) {
errorMessage = 'AccessKey activation error';
} else if (err instanceof CheetahErrors.CheetahActivationLimitError) {
Expand Down Expand Up @@ -217,7 +217,7 @@
<View style={styles.statusBar}>
<Text style={styles.statusBarText}>Cheetah</Text>
</View>
<View style={{flex: 6}}>

Check warning on line 220 in demo/react-native/App.tsx

View workflow job for this annotation

GitHub Actions / check-react-native-codestyle

Inline style: { flex: 6 }
<View style={styles.transcriptionBox}>
<ScrollView
ref={(el) => {
Expand All @@ -239,7 +239,7 @@
{this.state.appState === UIState.error && (
<View style={styles.errorBox}>
<Text
style={{

Check warning on line 242 in demo/react-native/App.tsx

View workflow job for this annotation

GitHub Actions / check-react-native-codestyle

Inline style: { color: 'white', fontSize: 16 }
color: 'white',
fontSize: 16,
}}>
Expand All @@ -249,7 +249,7 @@
)}

<View
style={{flex: 1, justifyContent: 'center', alignContent: 'center'}}>

Check warning on line 252 in demo/react-native/App.tsx

View workflow job for this annotation

GitHub Actions / check-react-native-codestyle

Inline style: { flex: 1, justifyContent: 'center', alignContent: 'center' }
<TouchableOpacity
style={[styles.buttonStyle, disabled ? styles.buttonDisabled : {}]}
onPress={() => this._toggleListening()}
Expand All @@ -260,7 +260,7 @@
</TouchableOpacity>
</View>

<View style={{flex: 0.5, justifyContent: 'center', paddingBottom: 10}}>

Check warning on line 263 in demo/react-native/App.tsx

View workflow job for this annotation

GitHub Actions / check-react-native-codestyle

Inline style: { flex: 0.5, justifyContent: 'center', paddingBottom: 10 }
<Text style={styles.instructions}>
Made in Vancouver, Canada by Picovoice
</Text>
Expand Down
6 changes: 6 additions & 0 deletions demo/react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ buildscript {
repositories {
google()
jcenter()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.3")
Expand All @@ -32,6 +35,9 @@ allprojects {

google()
jcenter()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
maven { url 'https://www.jitpack.io' }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Nov 02 11:32:43 PDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
8 changes: 4 additions & 4 deletions demo/react-native/ios/CheetahDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
DEVELOPMENT_TEAM = 65723695GD;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = CheetahDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand All @@ -320,7 +320,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 65723695GD;
INFOPLIST_FILE = CheetahDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -382,7 +382,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
Expand Down Expand Up @@ -434,7 +434,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
Expand Down
3 changes: 2 additions & 1 deletion demo/react-native/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
platform :ios, '13.0'

target 'CheetahDemo' do
config = use_native_modules!
pod 'Cheetah-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/cheetah/v2.0-ios/binding/ios/Cheetah-iOS.podspec'
use_react_native!(:path => config["reactNativePath"])
end
Loading
Loading