Skip to content

Commit d8fbfd3

Browse files
authored
Merge pull request #1 from FluidInference/remove-intel-mac-refs
- Remove isIntelMac from SystemInfo type - not relevant for iOS - Simplify native module - iOS is always ARM64 - Remove TurboModule/JSI/Zero-copy architecture docs from README - Update tests and mocks - add expo build
2 parents 3d60c4a + 192d549 commit d8fbfd3

23 files changed

Lines changed: 9182 additions & 125 deletions

.github/workflows/ci.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,49 @@ jobs:
7878
build \
7979
CODE_SIGNING_ALLOWED=NO
8080
81+
# Build Expo test app
82+
build-expo:
83+
name: Build Expo
84+
runs-on: macos-15
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v4
88+
89+
- name: Setup Node.js
90+
uses: actions/setup-node@v4
91+
with:
92+
node-version: '20'
93+
cache: 'npm'
94+
95+
- name: Install dependencies
96+
run: npm ci
97+
98+
- name: Build package
99+
run: npm run prepare
100+
101+
- name: Install expo-test dependencies
102+
run: cd expo-test && npm install
103+
104+
- name: Sync FluidAudio package
105+
run: cd expo-test && npm run sync-fluidaudio
106+
107+
- name: Generate native project
108+
run: cd expo-test && npx expo prebuild --platform ios --no-install
109+
110+
- name: Install CocoaPods
111+
run: cd expo-test/ios && pod install
112+
113+
- name: Build iOS
114+
run: |
115+
xcodebuild \
116+
-workspace expo-test/ios/expotest.xcworkspace \
117+
-scheme expotest \
118+
-configuration Debug \
119+
-sdk iphonesimulator \
120+
-destination 'platform=iOS Simulator,name=iPhone 16 Pro' \
121+
build \
122+
CODE_SIGNING_ALLOWED=NO
123+
81124
# Lint check
82125
lint:
83126
name: Lint
@@ -124,13 +167,15 @@ jobs:
124167

125168
- name: Verify exports
126169
run: |
170+
# Check that compiled files exist and export the expected symbols
127171
node -e "
128-
const pkg = require('./lib/commonjs/index.js');
172+
const fs = require('fs');
173+
const indexContent = fs.readFileSync('./lib/commonjs/index.js', 'utf8');
129174
const expected = ['ASRManager', 'StreamingASRManager', 'VADManager', 'DiarizationManager', 'TTSManager', 'getSystemInfo', 'isAppleSilicon', 'cleanup'];
130-
const missing = expected.filter(e => !pkg[e]);
175+
const missing = expected.filter(e => !indexContent.includes(e));
131176
if (missing.length) {
132177
console.error('Missing exports:', missing);
133178
process.exit(1);
134179
}
135-
console.log('All exports present');
180+
console.log('All exports found in compiled output');
136181
"

README.md

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ React Native wrapper for [FluidAudio](../FluidAudio) - a Swift library for ASR,
1212

1313
## Requirements
1414

15-
- iOS 17.0+ / macOS 14.0+
15+
- iOS 17.0+
1616
- React Native 0.71+
17-
- Apple Silicon (M1/M2/M3) - Intel Macs have limited support
1817

1918
## Installation
2019

@@ -34,8 +33,6 @@ Then install pods:
3433
cd ios && pod install
3534
```
3635

37-
**Note:** Requires **arm64** architecture (Apple Silicon). Simulator builds only work on M1/M2/M3 Macs.
38-
3936
## Usage
4037

4138
### Basic Transcription
@@ -150,17 +147,11 @@ await tts.synthesizeToFile('Hello, world!', '/path/to/output.wav');
150147
### System Information
151148

152149
```typescript
153-
import { getSystemInfo, isAppleSilicon } from 'react-native-fluidaudio';
150+
import { getSystemInfo } from 'react-native-fluidaudio';
154151

155152
const info = await getSystemInfo();
156153
console.log(info.summary);
157-
// e.g., "Apple M2 Pro, 16GB RAM, macOS 14.0"
158-
159-
if (await isAppleSilicon()) {
160-
// Full ML model support available
161-
} else {
162-
// Intel Mac - some models may not work
163-
}
154+
// e.g., "Apple A17 Pro, iOS 17.0"
164155
```
165156

166157
### Cleanup
@@ -196,67 +187,16 @@ await cleanup();
196187

197188
See [src/types.ts](./src/types.ts) for complete TypeScript definitions.
198189

199-
200190
## Notes
201191

202192
### Model Loading
203193

204194
First initialization downloads and compiles ML models (~500MB total). This can take 20-30 seconds as Apple's Neural Engine compiles the models. Subsequent loads use cached compilations (~1 second).
205195

206-
### Intel Mac Support
207-
208-
Most ML models require Apple Silicon (ARM64). On Intel Macs:
209-
- VAD works with CPU fallback
210-
- ASR/Diarization may not work
211-
- Use `isAppleSilicon()` to check before initializing
212-
213196
### TTS License
214197

215198
The TTS module uses ESpeakNG which is GPL licensed. Check license compatibility for your project.
216199

217-
## Architecture
218-
219-
This package supports both React Native architectures:
220-
221-
### New Architecture (Recommended)
222-
- **TurboModules** for type-safe native module interface
223-
- **JSI (JavaScript Interface)** for zero-copy audio buffer transfer
224-
- **Codegen** for automatic type synchronization
225-
226-
Enable New Architecture in your app:
227-
```bash
228-
# iOS
229-
cd ios && RCT_NEW_ARCH_ENABLED=1 pod install
230-
```
231-
232-
### Legacy Architecture
233-
- Falls back to Bridge-based modules automatically
234-
- Audio data transferred as base64 strings
235-
- Fully functional, slightly higher latency for large audio
236-
237-
### Zero-Copy API
238-
239-
When New Architecture is enabled, use `ArrayBuffer` methods for best performance:
240-
241-
```typescript
242-
import { ASRManager, hasZeroCopySupport } from 'react-native-fluidaudio';
243-
244-
// Check if zero-copy is available
245-
if (hasZeroCopySupport()) {
246-
console.log('Using JSI zero-copy audio transfer');
247-
}
248-
249-
const asr = new ASRManager();
250-
await asr.initialize();
251-
252-
// Zero-copy transcription (New Architecture)
253-
const audioBuffer = new ArrayBuffer(audioData.length);
254-
const result = await asr.transcribeBuffer(audioBuffer, 16000);
255-
256-
// Legacy API still works (falls back automatically)
257-
const result2 = await asr.transcribe(base64Audio, 16000);
258-
```
259-
260200
## License
261201

262202
MIT

__mocks__/react-native.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ export const NativeModules = {
44
FluidAudioModule: {
55
getSystemInfo: jest.fn().mockResolvedValue({
66
isAppleSilicon: true,
7-
isIntelMac: false,
87
platform: 'ios',
9-
summary: 'Mock Apple Silicon Device',
8+
summary: 'Mock iOS Device',
109
}),
1110
initializeAsr: jest.fn().mockResolvedValue({
1211
success: true,

__tests__/FluidAudio.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('FluidAudio', () => {
1818
const info = await getSystemInfo();
1919

2020
expect(info.isAppleSilicon).toBe(true);
21-
expect(info.isIntelMac).toBe(false);
2221
expect(info.platform).toBe('ios');
2322
expect(mockModule.getSystemInfo).toHaveBeenCalledTimes(1);
2423
});

__tests__/types.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe('Type Definitions', () => {
2020
it('should have correct shape', () => {
2121
const info: SystemInfo = {
2222
isAppleSilicon: true,
23-
isIntelMac: false,
2423
platform: 'ios',
2524
summary: 'Test device',
2625
};

example/README.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Example React Native app demonstrating the `react-native-fluidaudio` package.
44

55
## Requirements
66

7-
- macOS with Apple Silicon (M1/M2/M3/M4)
8-
- Xcode 15+
7+
- macOS with Xcode 15+
98
- Node.js 18+
109
- CocoaPods
1110

@@ -29,23 +28,9 @@ npm start
2928
npm run ios
3029
```
3130

32-
## New Architecture
33-
34-
To enable TurboModules and JSI zero-copy:
35-
36-
```bash
37-
# Clean and reinstall pods with New Architecture
38-
cd ios
39-
RCT_NEW_ARCH_ENABLED=1 pod install
40-
cd ..
41-
42-
# Run the app
43-
npm run ios
44-
```
45-
4631
## Features Demonstrated
4732

48-
- **System Info**: Shows device capabilities and architecture detection
33+
- **System Info**: Shows device capabilities
4934
- **ASR**: Speech-to-text initialization
5035
- **VAD**: Voice activity detection
5136
- **Diarization**: Speaker identification
@@ -55,4 +40,3 @@ npm run ios
5540

5641
- First run downloads ~500MB of ML models
5742
- Model compilation takes 20-30 seconds on first launch
58-
- Requires Apple Silicon for full ML model support

expo-test/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
.kotlin/
14+
*.orig.*
15+
*.jks
16+
*.p8
17+
*.p12
18+
*.key
19+
*.mobileprovision
20+
21+
# Metro
22+
.metro-health-check*
23+
24+
# debug
25+
npm-debug.*
26+
yarn-debug.*
27+
yarn-error.*
28+
29+
# macOS
30+
.DS_Store
31+
*.pem
32+
33+
# local env files
34+
.env*.local
35+
36+
# typescript
37+
*.tsbuildinfo
38+
39+
# generated native folders
40+
/ios
41+
/android

expo-test/App.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { StatusBar } from 'expo-status-bar';
2+
import { StyleSheet, Text, View } from 'react-native';
3+
import { useEffect, useState } from 'react';
4+
import { getSystemInfo } from '@fluidinference/react-native-fluidaudio';
5+
6+
export default function App() {
7+
const [status, setStatus] = useState('Loading...');
8+
const [info, setInfo] = useState(null);
9+
10+
useEffect(() => {
11+
async function test() {
12+
try {
13+
setStatus('Calling getSystemInfo...');
14+
const result = await getSystemInfo();
15+
16+
setInfo(result);
17+
setStatus('Success!');
18+
} catch (error) {
19+
setStatus(`Error: ${error.message}`);
20+
console.error('FluidAudio error:', error);
21+
}
22+
}
23+
test();
24+
}, []);
25+
26+
return (
27+
<View style={styles.container}>
28+
<Text style={styles.title}>FluidAudio Expo Test</Text>
29+
<Text style={styles.status}>{status}</Text>
30+
{info && (
31+
<View style={styles.infoBox}>
32+
<Text style={styles.infoText}>Platform: {info.platform}</Text>
33+
<Text style={styles.infoText}>Apple Silicon: {info.isAppleSilicon ? 'Yes' : 'No'}</Text>
34+
<Text style={styles.infoText}>Summary: {info.summary}</Text>
35+
</View>
36+
)}
37+
<StatusBar style="auto" />
38+
</View>
39+
);
40+
}
41+
42+
const styles = StyleSheet.create({
43+
container: {
44+
flex: 1,
45+
backgroundColor: '#fff',
46+
alignItems: 'center',
47+
justifyContent: 'center',
48+
padding: 20,
49+
},
50+
title: {
51+
fontSize: 24,
52+
fontWeight: 'bold',
53+
marginBottom: 20,
54+
},
55+
status: {
56+
fontSize: 16,
57+
color: '#666',
58+
marginBottom: 20,
59+
textAlign: 'center',
60+
},
61+
infoBox: {
62+
backgroundColor: '#f0f0f0',
63+
padding: 20,
64+
borderRadius: 10,
65+
},
66+
infoText: {
67+
fontSize: 14,
68+
marginBottom: 5,
69+
},
70+
});

expo-test/app.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"expo": {
3+
"name": "expo-test",
4+
"slug": "expo-test",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/icon.png",
8+
"userInterfaceStyle": "light",
9+
"newArchEnabled": false,
10+
"splash": {
11+
"image": "./assets/splash-icon.png",
12+
"resizeMode": "contain",
13+
"backgroundColor": "#ffffff"
14+
},
15+
"ios": {
16+
"supportsTablet": true,
17+
"bundleIdentifier": "com.fluidaudio.expotest",
18+
"deploymentTarget": "17.0"
19+
},
20+
"android": {
21+
"adaptiveIcon": {
22+
"foregroundImage": "./assets/adaptive-icon.png",
23+
"backgroundColor": "#ffffff"
24+
},
25+
"edgeToEdgeEnabled": true
26+
},
27+
"web": {
28+
"favicon": "./assets/favicon.png"
29+
}
30+
}
31+
}

expo-test/assets/adaptive-icon.png

17.1 KB
Loading

0 commit comments

Comments
 (0)