Skip to content

Commit 20bec7b

Browse files
authored
iOS lib to framework (Picovoice#69)
1 parent 133691a commit 20bec7b

File tree

60 files changed

+1737
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1737
-174
lines changed

binding/flutter/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
* Minor fix
66

77
## [1.6.2] - 2020-01-18
8-
* Updated Rhino iOS lib
8+
* Updated Rhino iOS lib
9+
10+
## [1.6.3] - 2021-02-05
11+
* Rhino iOS lib to framework

binding/flutter/copy_resources.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ echo "Copying Android libs..."
88
cp -rp ../../lib/android/* ./android/src/main/jniLibs
99

1010
echo "Copying iOS libs..."
11-
cp ../../lib/ios/libpv_rhino.a ./ios/pv_rhino/libpv_rhino.a
12-
cp ../../include/picovoice.h ./ios/pv_rhino/picovoice.h
13-
cp ../../include/pv_rhino.h ./ios/pv_rhino/pv_rhino.h
11+
cp -R ../../lib/ios/PvRhino.xcframework ./ios/PvRhino.xcframework
1412

1513
echo "Creating model resources directory..."
1614
if [ ! -d "./assets/lib/common" ]

binding/flutter/ios/Classes/SwiftRhinoPlugin.swift

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,9 @@
1111

1212
import Flutter
1313
import UIKit
14-
import pv_rhino
1514

1615
public class SwiftRhinoPlugin: NSObject, FlutterPlugin {
1716
public static func register(with registrar: FlutterPluginRegistrar) {
1817

1918
}
20-
21-
22-
// these dummy function calls are required to prevent the linker from
23-
// stripping the rhino static library
24-
public func doNotCallThisFunction_rhinoVersion(){
25-
pv_rhino_version();
26-
}
27-
28-
public func doNotCallThisFunction_rhinoInit(modelPath: String, contextPath: String, sensitivity: Float32){
29-
var rhino:OpaquePointer?
30-
let _ = pv_rhino_init(
31-
modelPath,
32-
contextPath,
33-
sensitivity,
34-
&rhino);
35-
}
36-
37-
public func doNotCallThisFunction_rhinoContextInfo(rhino:OpaquePointer?){
38-
var cContextInfo: UnsafePointer<Int8>?
39-
pv_rhino_context_info(rhino, &cContextInfo);
40-
}
41-
42-
public func doNotCallThisFunction_rhinoFrameLength(){
43-
pv_rhino_frame_length()
44-
}
45-
46-
public func doNotCallThisFunction_rhinoSampleRate(){
47-
pv_sample_rate()
48-
}
49-
50-
public func doNotCallThisFunction_rhinoProcess(rhino:OpaquePointer?, pcm:[Int16]){
51-
var isFinalized:Bool = false
52-
pv_rhino_process(rhino, pcm, &isFinalized)
53-
54-
var isUnderstood: Bool = false
55-
pv_rhino_is_understood(rhino, &isUnderstood)
56-
57-
var cIntent: UnsafePointer<Int8>?
58-
var numSlots: Int32 = 0
59-
var cSlotKeys: UnsafeMutablePointer<UnsafePointer<Int8>?>?
60-
var cSlotValues: UnsafeMutablePointer<UnsafePointer<Int8>?>?
61-
pv_rhino_get_intent(rhino, &cIntent, &numSlots, &cSlotKeys, &cSlotValues)
62-
63-
pv_rhino_free_slots_and_values(rhino, cSlotKeys, cSlotValues)
64-
pv_rhino_reset(rhino)
65-
}
66-
67-
public func doNotCallThisFunction_rhinoDelete(rhino:OpaquePointer?){
68-
pv_rhino_delete(rhino)
69-
}
7019
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>AvailableLibraries</key>
6+
<array>
7+
<dict>
8+
<key>LibraryIdentifier</key>
9+
<string>ios-arm64_armv7</string>
10+
<key>LibraryPath</key>
11+
<string>PvRhino.framework</string>
12+
<key>SupportedArchitectures</key>
13+
<array>
14+
<string>arm64</string>
15+
<string>armv7</string>
16+
</array>
17+
<key>SupportedPlatform</key>
18+
<string>ios</string>
19+
</dict>
20+
<dict>
21+
<key>LibraryIdentifier</key>
22+
<string>ios-arm64_i386_x86_64-simulator</string>
23+
<key>LibraryPath</key>
24+
<string>PvRhino.framework</string>
25+
<key>SupportedArchitectures</key>
26+
<array>
27+
<string>arm64</string>
28+
<string>i386</string>
29+
<string>x86_64</string>
30+
</array>
31+
<key>SupportedPlatform</key>
32+
<string>ios</string>
33+
<key>SupportedPlatformVariant</key>
34+
<string>simulator</string>
35+
</dict>
36+
</array>
37+
<key>CFBundlePackageType</key>
38+
<string>XFWK</string>
39+
<key>XCFrameworkFormatVersion</key>
40+
<string>1.0</string>
41+
</dict>
42+
</plist>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <Foundation/Foundation.h>
2+
3+
//! Project version number for PvRhino.
4+
FOUNDATION_EXPORT double PvRhinoVersionNumber;
5+
6+
//! Project version string for PvRhino.
7+
FOUNDATION_EXPORT const unsigned char PvRhinoVersionString[];

binding/flutter/ios/pv_rhino/picovoice.h renamed to binding/flutter/ios/PvRhino.xcframework/ios-arm64_armv7/PvRhino.framework/Headers/picovoice.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#ifndef PICOVOICE_H
1313
#define PICOVOICE_H
1414

15+
#include <stdint.h>
16+
1517
#ifdef __cplusplus
1618

1719
extern "C"
@@ -24,7 +26,7 @@ extern "C"
2426
/**
2527
* Audio sample rate accepted by Picovoice.
2628
*/
27-
PV_API int pv_sample_rate(void);
29+
PV_API int32_t pv_sample_rate(void);
2830

2931
/**
3032
* Status codes.

binding/flutter/ios/pv_rhino/pv_rhino.h renamed to binding/flutter/ios/PvRhino.xcframework/ios-arm64_armv7/PvRhino.framework/Headers/pv_rhino.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,50 @@ extern "C"
3434
*/
3535
typedef struct pv_rhino pv_rhino_t;
3636

37+
#if defined(__PV_NO_DYNAMIC_MEMORY__) && defined(__PV_NO_FILE_SYSTEM__)
38+
39+
/**
40+
* Constructor.
41+
*
42+
* @param memory Memory needs to be 8-byte aligned.
43+
* @param memory_size Memory size in bytes.
44+
* @param context Context parameters. A context represents the set of expressions (spoken commands), intents, and intent
45+
* arguments (slots) within a domain of interest.
46+
* @param context_size Size of the context in bytes.
47+
* @param sensitivity Inference sensitivity. It should be a number within [0, 1]. A higher sensitivity value results in
48+
* fewer misses at the cost of (potentially) increasing the erroneous inference rate.
49+
* @param[out] object Constructed Speech-to-Intent object.
50+
* @return Status code. Returns 'PV_STATUS_INVALID_ARGUMENT' or 'PV_STATUS_OUT_OF_MEMORY' on failure.
51+
*/
52+
PV_API pv_status_t pv_rhino_init(
53+
void *memory_buffer,
54+
int32_t memory_size,
55+
const void *context,
56+
int32_t context_size,
57+
float sensitivity,
58+
pv_rhino_t **object);
59+
60+
#elif !defined(__PV_NO_DYNAMIC_MEMORY__) && defined(__PV_NO_FILE_SYSTEM__)
61+
62+
/**
63+
* Constructor.
64+
*
65+
* @param context Context parameters. A context represents the set of expressions (spoken commands), intents, and intent
66+
* arguments (slots) within a domain of interest.
67+
* @param context_size Size of context in bytes.
68+
* @param sensitivity Inference sensitivity. It should be a number within [0, 1]. A higher sensitivity value results in
69+
* fewer misses at the cost of (potentially) increasing the erroneous inference rate.
70+
* @param[out] object Constructed Speech-to-Intent object.
71+
* @return Status code. Returns 'PV_STATUS_INVALID_ARGUMENT' or 'PV_STATUS_OUT_OF_MEMORY' on failure.
72+
*/
73+
PV_API pv_status_t pv_rhino_init(
74+
const void *context,
75+
int32_t context_size,
76+
float sensitivity,
77+
pv_rhino_t **object);
78+
79+
#elif !defined(__PV_NO_DYNAMIC_MEMORY__) && !defined(__PV_NO_FILE_SYSTEM__)
80+
3781
/**
3882
* Constructor.
3983
*
@@ -52,6 +96,12 @@ PV_API pv_status_t pv_rhino_init(
5296
float sensitivity,
5397
pv_rhino_t **object);
5498

99+
#else
100+
101+
#error
102+
103+
#endif
104+
55105
/**
56106
* Destructor.
57107
*
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework module PvRhino {
2+
umbrella header "PvRhino.h"
3+
header "pv_rhino.h"
4+
header "picovoice.h"
5+
export *
6+
module * {export *}
7+
}
Binary file not shown.

0 commit comments

Comments
 (0)