Skip to main content
Version: 4.x.x

Realtime Transcription - iOS

Realtime transcription allows you to transcribe audio content into text in real-time during a session. This guide will walk you through using the startTranscription() and stopTranscription() functions to manage realtime transcription in your application.

You can also set up webhooks for realtime transcription.

important

Please ensure eligibility prior to enabling realtime transcription. For further details, please contact us.

Integrating Realtime Transcription Feature​

alt text

The image above shows these steps:

  1. Start Transcription: The SDK Client initiates real-time transcription using the startTranscription method.

  2. Server Response: VideoSDK starts transcription for the room, or refuses the request.

    • If the request is denied, startTranscription() throws a VideoSDKError, such as START_TRANSCRIPTION_FAILED (4031).
    • If the request is successful, the client receives the onTranscriptionStateChanged event with TRANSCRIPTION_STARTED, indicating that transcription has begun.
  3. Transcription Data: As transcription progresses, the client receives the onTranscriptionText event with data such as the text itself, the speaker's participant ID and name, and timestamp. Its type is .REALTIME for a partial result that can still change, .FULL_SENTENCE for the settled sentence, or nil.

  4. Stop Transcription: The client stops transcription with the stopTranscription() method.

    • The client then receives the onTranscriptionStateChanged event with TRANSCRIPTION_STOPPED to confirm that transcription has ended.

Step 1: Configure Realtime Transcription​

  • In this step, we set up the configuration for realtime transcription. We define the webhook URL where the webhooks will be received.
  • TranscriptionConfig(webhookURL:summary:modelConfig:) takes only optional fields. modelConfig must be JSON-serializable, or startTranscription() throws ERROR_INVALID_PARAMETER.
// Realtime Transcription Configuration
let config = TranscriptionConfig(
webhookURL: "YOUR_WEBHOOK_URL",
summary: SummaryConfig(
enabled: true,
prompt: "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
)
)

Step 2: Start realtime transcription​

  • Initiate the realtime transcription using the startTranscription() method.
  • startTranscription() is async throws. Call it with try await inside a Task, after you join the room.
// Starts realtime transcription
@IBAction func startTranscriptionTapped(_ sender: Any) {

let config = TranscriptionConfig(
webhookURL: "YOUR_WEBHOOK_URL",
summary: SummaryConfig(
enabled: true,
prompt: "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
)
)

Task {
do {
try await room?.startTranscription(config: config)
} catch {
print("Failed to start transcription: \(error)")
}
}
}

Step 3: Stop realtime transcription​

  • Terminate the realtime transcription using the stopTranscription() method. It is also async throws.
// Stops realtime transcription
@IBAction func stopTranscriptionTapped(_ sender: Any) {
Task {
do {
try await room?.stopTranscription()
} catch {
print("Failed to stop transcription: \(error)")
}
}
}

Step 4: Listen for transcription events​

  • Here, we configure the callback methods for transcription events.
import VideoSDKRTC

extension RoomViewController: RoomEventListener {

// Listen for transcription state changed event
func onTranscriptionStateChanged(state: TranscriptionState) {

switch state {
case .TRANSCRIPTION_STARTING:
print("transcription starting")

case .TRANSCRIPTION_STARTED:
print("transcription started")

case .TRANSCRIPTION_STOPPING:
print("transcription stopping")

case .TRANSCRIPTION_STOPPED:
print("transcription stopped")

@unknown default:
break
}

}

// Listen for transcription text event
func onTranscriptionText(_ data: TranscriptionText) {
print("transcription text: ", data.text)
print("participant name", data.participantName)
}
}
tip

To show the text in each participant's own language, use real-time translation. Each participant sets a language with the translationLanguage parameter of createRoom() or with changeTranslationLanguage(_:). After you call startTranslation(), each participant receives the translated text through onTranslationText(_:). See Realtime Translation for a step-by-step guide.

API Reference​

The API references for all the methods utilized in this guide are provided below.

Got a Question? Ask us on discord