Apple quick start
The Swift package for iOS and macOS: the install line, where the key goes, and the quick start.
The Swift package runs on iOS and macOS, on Apple silicon. It uses the Neural Engine where the device has tested it against the exact CPU engine, and the CPU engine otherwise. The source is at github.com/Quran-Lab/tajweedformer-apple.
Install
// Package.swift, or in Xcode: File > Add Package Dependencies
.package(url: "https://github.com/Quran-Lab/tajweedformer-apple", from: "3.1.4")
// product TajweedFormer
import TajweedFormerThe key
An iOS app uses an apps key and its macOS build a desktop key: two keys. The app is identified by its bundle id. Keep the key out of your repository:
// Secrets.xcconfig (git-ignored), the target's base configuration
QURANLAB_KEY = qlk_v1_...
// Info.plist: QuranLabKey = $(QURANLAB_KEY)
let key = Bundle.main.object(forInfoDictionaryKey: "QuranLabKey") as? StringAdd the App Attest capability: it proves your app's install, and the recordings learners share are not uploaded without it (recording sharing).
Client, model, listen, read
import TajweedFormer
func quickStart(key: String) async throws {
// once per process
let client = try TajweedClient(key: key)
// downloads the model once, verifies it, opens and warms it
let model = try await client.model()
// asks for the microphone; 1.5 s of silence end the take
let session = try await model.listen(options: .init(endOnSilenceMs: 1500))
for await chunk in session.chunks { // every 320 ms
print(chunk.decoded.text) // what the model heard so far
}
}Call it from a button: Task { try await quickStart(key: key) }.
- The microphone.
listen()asks for the permission, captures at the device's own rate and carries that rate to the session, so no sample rate appears here. - The end of a take. With
endOnSilenceMsthe take finishes by itself 1.5 s after the learner stops; without it, calltry await session.finish(). - The next take is a new
model.listen(). - Errors. Every error is a
TajweedErrorwith a stablecode, afixand a link into Errors.
What comes back
Each chunk carries chunk.decoded (the text, each token with its times and confidence, and how many tokens are settled) and chunk.heads (the raw outputs you selected). Build your own feedback says what each of them is.
The exact names for your SDK version are in the package's README.