Skip to content

Commit

Permalink
Merge pull request #2267 from 100mslive/pawan-100ms-patch-3
Browse files Browse the repository at this point in the history
Update captions.mdx
  • Loading branch information
KaustubhKumar05 authored Jun 11, 2024
2 parents 3cc72b5 + 9d84877 commit 3a1ee80
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions docs/ios/v2/how-to-guides/set-up-video-conferencing/captions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ The SDK provides a callback with the transcript for each peer when they speak.

## Minimum Requirements

- Minimum 100ms SDK version required is 1.9.0
- Minimum 100ms SDK version required is 1.12.0

## How to check if captions are started in a room?

To check if live captions are enabled in a room, check if transcriptionState of type caption is in started state in HMSRoom object like below:

```swift
let captionsEnabled = hmsSDK.room?.transcriptionStates?.first { $0.state == HMSTranscriptionStatus.started } != nil }
```

## How to implement closed captioning?

Implement `on(transcripts: HMSTranscripts)` from `HMSUpdateListener` callback like below:

```swift
public func on(transcripts: HMSTranscripts) {
transcripts.transcripts.forEach { transcript in
// handle transcript
}
public func on(transcripts: HMSTranscripts) {
transcripts.transcripts.forEach { transcript in
// handle transcript
}
}
```
Expand Down Expand Up @@ -51,5 +58,27 @@ Here is an example implemenation:
lastTranscript = transcript
}
}
}
```

## How to toggle Live Transcriptions on/off
You can toggle live transcriptions on/off at runtime that can help save costs. Use startTranscription() method to start the transcription and stopTranscription() method to stop transcription like below:
```swift
// Start Real Time Transcription
sdk.startTranscription() { success, error in
if let error = error {
// handle error
} else {
// success
}
}

// Stop Real Time Transcription
sdk.stopTranscription() { success, error in
if let error = error {
// handle error
} else {
// success
}
}
```

0 comments on commit 3a1ee80

Please sign in to comment.