Primordial SDK
Login

Voice

Record and transcribe in mobile apps.

Primordial voice APIs prepare local speech models, request permissions, record audio, and return transcripts plus captured audio data.

This page was auto-generated by OpenAI's GPT5.5. We are refining it to make it more helpful.

Permissions

Add microphone and speech-recognition usage descriptions to your app Info.plist.

<key>NSMicrophoneUsageDescription</key>
<string>This app records audio for transcription.</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>This app uses speech recognition for transcription.</string>

Download And Load Voice Models

import Primordial

@MainActor
func downloadVoiceModels() async throws {
    let primordial = PrimordialClient()
    let models = primordial.voiceModelManager()

    try await models.download { progress in
        print(progress.fractionCompleted)
        print(progress.phase)
    }

    try await models.load()
    print(models.isReady)
}

Record And Transcribe

import Primordial

@MainActor
func recordNote() async throws {
    let primordial = PrimordialClient()
    let models = primordial.voiceModelManager()

    try await models.downloadAndLoad()

    let recorder = primordial.voiceRecorder(modelManager: models)
    guard await recorder.requestAuthorization() else {
        return
    }

    try await recorder.startRecording()

    let result = try await recorder.stopRecording()
    print(result.transcript)
}

Live Updates

@MainActor
func observe(recorder: PrimordialVoiceRecorder) {
    Task { @MainActor in
        for await update in recorder.updates {
            print(update.liveTranscript)
            print(update.finalTranscript)
            print(update.isFinal)
            print(update.isDualTrack)
        }
    }
}

Recorded Audio

let result = try await recorder.stopRecording()

print(result.transcript)

if let audioData = result.audioData {
    let url = FileManager.default.temporaryDirectory
        .appendingPathComponent("recording.m4a")

    try audioData.write(to: url)
    print("Saved audio:", url)
}

Recorder Controls

try await recorder.startRecording()
await recorder.pauseRecording()
try await recorder.resumeRecording()
let result = try await recorder.stopRecording()