Skip to content

Commit

Permalink
Falcon ios (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
albho authored Apr 24, 2024
1 parent 5455a9a commit cdf4966
Show file tree
Hide file tree
Showing 80 changed files with 4,104 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ body:
label: SDK
options:
- C
- iOS
- Python
- Web
- Android
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/ios-appcenter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: iOS AppCenter Tests

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- '.github/workflows/ios-appcenter.yml'
- 'binding/ios/FalconAppTest/**'
- 'resources/audio_samples/**'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- '.github/workflows/ios-appcenter.yml'
- 'binding/ios/FalconAppTest/**'
- 'resources/audio_samples/**'

defaults:
run:
working-directory: binding/ios/FalconAppTest

jobs:
build:
name: Run iOS Tests on AppCenter
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3

- name: Install Cocoapods
run: gem install cocoapods

- name: Install AppCenter CLI
run: npm install -g appcenter-cli

- name: Make build dir
run: mkdir ddp

- name: Install resource script dependency
run: |
brew update
brew install convmv
- name: Copy test_resources
run: ./copy_test_resources.sh

- name: Run Cocoapods
run: pod install

- name: Inject AppID
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:'
FalconAppTestUITests/FalconAppTestUITests.swift

- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace FalconAppTest.xcworkspace
-sdk iphoneos
-scheme FalconAppTest
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO

- name: Run Tests on AppCenter
run: appcenter test run xcuitest
--token ${{secrets.APPCENTERAPITOKEN}}
--app "Picovoice/Falcon-iOS"
--devices "Picovoice/ios-min-max"
--test-series "falcon-ios"
--locale "en_US"
--build-dir ddp/Build/Products/Debug-iphoneos
52 changes: 52 additions & 0 deletions .github/workflows/ios-demos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: iOS Demos

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'demo/ios/FalconDemo/**'
- '.github/workflows/ios-demos.yml'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- 'demo/ios/FalconDemo/**'
- '.github/workflows/ios-demos.yml'

defaults:
run:
working-directory: demo/ios/FalconDemo

jobs:
build:
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Node.js LTS
uses: actions/setup-node@v3
with:
node-version: lts/*

- name: Install Cocoapods
run: gem install cocoapods

- name: Install AppCenter CLI
run: npm install -g appcenter-cli

- name: Make build dir
run: mkdir ddp

- name: Run Cocoapods
run: pod install

- name: Build
run: xcrun xcodebuild build
-configuration Debug
-workspace FalconDemo.xcworkspace
-sdk iphoneos
-scheme FalconDemo
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO
89 changes: 89 additions & 0 deletions .github/workflows/ios-perf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: iOS Performance

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'lib/ios/**'
- 'lib/common/**'
- '.github/workflows/ios-perf.yml'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- 'lib/ios/**'
- 'lib/common/**'
- '.github/workflows/ios-perf.yml'

defaults:
run:
working-directory: binding/ios/FalconAppTest

jobs:
build:
name: Run iOS Tests on AppCenter
runs-on: macos-latest

strategy:
matrix:
device: [ios-perf]
include:
- device: ios-perf
procPerformanceThresholdSec: 0.5

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3

- name: Install Cocoapods
run: gem install cocoapods

- name: Install AppCenter CLI
run: npm install -g appcenter-cli

- name: Make build dir
run: mkdir ddp

- name: Install resource script dependency
run: |
brew update
brew install convmv
- name: Copy test_resources
run: ./copy_test_resources.sh

- name: Run Cocoapods
run: pod install

- name: Inject AppID
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:'
PerformanceTest/PerformanceTest.swift

- name: Inject Number of Iterations
run: sed -i '.bak' 's:{NUM_TEST_ITERATIONS}:100:'
PerformanceTest/PerformanceTest.swift

- name: Inject Performance Threshold
run: sed -i '.bak' 's:{PROC_PERFORMANCE_THRESHOLD_SEC}:${{ matrix.procPerformanceThresholdSec }}:'
PerformanceTest/PerformanceTest.swift

- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace FalconAppTest.xcworkspace
-sdk iphoneos
-scheme PerformanceTest
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO

- name: Run Tests on AppCenter
run: appcenter test run xcuitest
--token ${{secrets.APPCENTERAPITOKEN}}
--app "Picovoice/Falcon-iOS"
--devices "Picovoice/${{ matrix.device }}"
--test-series "falcon-ios"
--locale "en_US"
--build-dir ddp/Build/Products/Debug-iphoneos
60 changes: 51 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![GitHub](https://img.shields.io/github/license/Picovoice/falcon)](https://github.com/Picovoice/falcon/)

[![Maven Central](https://img.shields.io/maven-central/v/ai.picovoice/falcon-android?label=maven-central%20%5Bandroid%5D)](https://repo1.maven.org/maven2/ai/picovoice/falcon-android/)
[![CocoaPods](https://img.shields.io/cocoapods/v/Falcon-iOS)](https://cocoapods.org/pods/Falcon-iOS)<!-- markdown-link-check-disable-line -->
[![npm](https://img.shields.io/npm/v/@picovoice/falcon-web?label=npm%20%5Bweb%5D)](https://www.npmjs.com/package/@picovoice/falcon-web)
[![PyPI](https://img.shields.io/pypi/v/pvfalcon)](https://pypi.org/project/pvfalcon/)

Expand All @@ -16,9 +17,10 @@ Falcon is an on-device speaker diarization engine. Falcon is:

- Private; All voice processing runs locally.
- Cross-Platform:
- Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64)
- Raspberry Pi (3, 4, 5) and NVIDIA Jetson Nano
- Chrome, Safari, Firefox, and Edge
- Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64)
- Raspberry Pi (3, 4, 5) and NVIDIA Jetson Nano
- Android and iOS
- Chrome, Safari, Firefox, and Edge

## Table of Contents

Expand All @@ -30,11 +32,13 @@ Falcon is an on-device speaker diarization engine. Falcon is:
- [Python Demo](#python-demo)
- [C Demo](#c-demo)
- [Web Demo](#web-demo)
- [iOS Demo](#ios-demo)
- [Android Demo](#android-demo)
- [SDKs](#sdks)
- [Python](#python)
- [C](#c)
- [Web](#web)
- [iOS](#ios)
- [Android](#android)
- [Releases](#releases)
- [FAQ](#faq)
Expand Down Expand Up @@ -108,6 +112,18 @@ npm run start

Open `http://localhost:5000` in your browser to try the demo.

### iOS Demo

To run the demo, go to [demo/ios/FalconDemo](./demo/ios/FalconDemo) and run:

```console
pod install
```

Replace `let accessKey = "${YOUR_ACCESS_KEY_HERE}"` in the file [ViewModel.swift](./demo/ios/FalconDemo/FalconDemo/ViewModel.swift) with your `AccessKey`.

Then, using [Xcode](https://developer.apple.com/xcode/), open the generated `FalconDemo.xcworkspace` and run the application.

### Android Demo

Using Android Studio, open [demo/android/FalconDemo](./demo/android/FalconDemo) as an Android project and then run the application.
Expand Down Expand Up @@ -206,25 +222,51 @@ npm install --save @picovoice/falcon-web
Create an instance of the engine using `FalconWorker` and diarize an audio file:

```typescript
import { Falcon } from "@picovoice/falcon-web";
import falconParams from "${PATH_TO_BASE64_FALCON_PARAMS}";
import { Falcon } from '@picovoice/falcon-web';
import falconParams from '${PATH_TO_BASE64_FALCON_PARAMS}';

function getAudioData(): Int16Array {
// ... function to get audio data
return new Int16Array();
}

const falcon = await FalconWorker.create(
"${ACCESS_KEY}",
{ base64: falconParams }
);
const falcon = await FalconWorker.create('${ACCESS_KEY}', {
base64: falconParams,
});

const { segments } = await falcon.process(getAudioData());
console.log(segments);
```

Replace `${ACCESS_KEY}` with yours obtained from [Picovoice Console](https://console.picovoice.ai/). Finally, when done release the resources using `falcon.release()`.

### iOS

<!-- markdown-link-check-disable -->

The Falcon iOS binding is available via [CocoaPods](https://cocoapods.org/pods/Falcon-iOS). To import it into your iOS project, add the following line to your Podfile and run `pod install`:

<!-- markdown-link-check-enable -->

```ruby
pod 'Falcon-iOS'
```

Create an instance of the engine and perform speaker diarization on an audio_file:

```swift
import Falcon

let falcon = Falcon(accessKey: "${ACCESS_KEY}")

do {
let audioPath = Bundle(for: type(of: self)).path(forResource: "${AUDIO_FILE_NAME}", ofType: "${AUDIO_FILE_EXTENSION}")
let segments = falcon.process(audioPath)
} catch { }
```

Replace `${ACCESS_KEY}` with yours obtained from Picovoice Console, `${AUDIO_FILE_NAME}` with the name of the audio file and `${AUDIO_FILE_EXTENSION}` with the extension of the audio file.

### Android

To include the Falcon package in your Android project, ensure you have included `mavenCentral()` in your top-level `build.gradle` file and then add the following to your app's `build.gradle`:
Expand Down
22 changes: 22 additions & 0 deletions binding/ios/Falcon-iOS.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Pod::Spec.new do |s|
s.name = 'Falcon-iOS'
s.module_name = 'Falcon'
s.version = '1.0.0'
s.license = {:type => 'Apache 2.0'}
s.summary = 'iOS SDK for Picovoice\'s Falcon speaker diarization engine.'
s.description =
<<-DESC
Falcon is an on-device speaker diarization engine that identifies speakers
in an audio stream by finding speaker change points and grouping speech segments
based on speaker voice characteristics.
DESC
s.homepage = 'https://github.com/Picovoice/falcon/tree/main/binding/ios'
s.author = { 'Picovoice' => '[email protected]' }
s.source = { :git => "https://github.com/Picovoice/falcon.git", :branch => "falcon-ios" }
s.ios.deployment_target = '13.0'
s.swift_version = '5.0'
s.vendored_frameworks = 'lib/ios/PvFalcon.xcframework'
s.resources = 'lib/common/falcon_params.pv'
s.source_files = 'binding/ios/*.{swift}'
s.exclude_files = 'binding/ios/FalconTestApp/**'
end
Loading

0 comments on commit cdf4966

Please sign in to comment.