File size: 3,891 Bytes
64f7370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Getting Started

This guide explains how to reproduce the ASR-only iPhone package from a fresh
checkout.

## 1. Install Xcode and XcodeGen

Install the full Xcode app from the Mac App Store. Command Line Tools alone are
not enough for iPhone signing, Simulator runtimes, or the full Swift test stack.

```bash
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
sudo xcodebuild -license accept
xcodebuild -version

brew install xcodegen
xcodegen --version
```

## 2. Check the Swift Package

```bash
cd SpeechKit
swift package resolve
swift build
swift run dev-check
swift test
cd ..
```

`dev-check` is intentionally lightweight. It validates asset-manifest logic,
mel bucket selection, and audio-token accounting without loading the 400 MB
model bundle.

## 3. Run File Transcription on macOS

`asrkit-cli --file` uses the same public `ASRTranscriber` API as apps.

```bash
cd SpeechKit
swift run -c release asrkit-cli .. --file /path/to/audio.wav
swift run -c release asrkit-cli .. --file /path/to/audio.wav --repeat 10
cd ..
```

The model bundle is expected at `dist/ASRModels.bundle`.

## 4. Generate the iOS Demo

```bash
cd ASRDemo
xcodegen generate
open ASRDemo.xcodeproj
```

`ASRDemo/project.yml` is the source of truth. Regenerate the project after
changing resources, build settings, or dependencies.

## 5. Configure Signing

In Xcode:

1. Open the navigator with `Cmd+1`.
2. Select the top-level blue `ASRDemo` project item.
3. Select the `ASRDemo` target.
4. Open `Signing & Capabilities`.
5. Choose your Apple Developer team.
6. Change the bundle identifier from `com.example.asrdemo` to a unique value.

The generated Info.plist includes `NSMicrophoneUsageDescription`, so the
microphone permission prompt is available when recording.

## 6. Test on Simulator

Choose an iOS Simulator destination and press Run. Simulator is useful for:

- Launch and resource packaging checks.
- Basic UI validation.
- Smoke-testing model loading and transcription.
- Watching memory trends during repeated runs.

Simulator memory footprint is not equivalent to a real iPhone. The Simulator is
a macOS process and does not follow iOS memory pressure and Jetsam rules. Use a
physical iPhone for final footprint, thermal, and power validation.

## 7. Test on iPhone

1. Connect the iPhone with USB.
2. Trust the Mac on the iPhone.
3. Enable Developer Mode if iOS asks for it.
4. In Xcode, open `Window` -> `Devices and Simulators` and confirm the phone is paired.
5. Select the physical iPhone as the run destination.
6. Run the `ASRDemo` scheme.

First launch can be slow because Core ML loads and compiles ANE programs. Later
launches usually reuse the system cache.

## 8. Use the Demo

The public demo is ASR-only:

- `Record`: captures microphone audio, then transcribes once after stop.
- `Repeat Last 10x`: re-runs the last recording ten times for quick stability
  checks on a physical iPhone.

The public package does not include sample media; use `asrkit-cli --file` for
file tests without modifying the app target.

The demo also shows:

- Stage timings for mel extraction, audio tower, decoder, and total latency.
- Token diagnostics for short-output debugging.
- Process memory footprint, peak footprint, CPU, thermal state, battery state,
  and a rough whole-device power estimate.

Streaming and VAD are not included in this ASR-only build.

## 9. Run the ANE Benchmark

```bash
cd ANEBench
xcodegen generate
open ANEBench.xcodeproj
```

Sign the `ANEBench` target the same way as `ASRDemo`, then run it on a physical
iPhone. The benchmark loads `dist/ASRModels.bundle/tower.mlmodelc` and measures
the `tower_5s`, `tower_10s`, and `tower_30s` Core ML functions with
`.cpuAndNeuralEngine`.

The sustained-load button is intended for Instruments Energy / Power profiling.
It is not representative of normal one-shot ASR duty cycle.