Live Captioning for Livestreams - iOS
Live captioning enhances your livestreams by converting hosts' speech into text in real-time, boosting accessibility and engagement. Using the startTranscription()
and stopTranscription()
functions you can enable or disable captions on the fly, and display captions dynamically in your UI for all viewers.
Video SDK offers flexible configuration and event-driven updates to help you integrate captions seamlessly into your broadcast layout.
startTranscription()
​
The startTranscription()
method, accesible from the meeting
object, is used to initiate live captions in a live stream. This method accepts the following two parameters:
-
1. webhookUrl (optional)
: This is the webhook URL where you can listen to events related to the recording, such as the start and stop of recording. It triggers when the recording is completed and stored on the server. You can learn more about webhooks here -
2. summary (optional)
:enabled
: Indicates whether realtime transcription summary generation is enabled. Summary will be available after realtime transcription stopped. Default: false.prompt
: provides guidelines or instructions for generating a custom summary based on the realtime transcription content.
stopTranscription()
​
The stopTranscription()
method, accesible from the useMeeting
object, is used to stop the live captions in a live stream.
Example​
@IBAction func startLiveCaptionTapped(_ 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"
)
)
meeting.startTranscription(config);
}
@IBAction func stopLiveCaptionTapped(_ sender: Any) {
meeting.stopTranscription();
}
Events associated with live captioning​
- All participants-including all the hosts and audience members will receive a callback on the
onTranscriptionStateChanged
event with the current state of the captioning. - All participants-including all the hosts and audience members will receive a callback on the
onTranscriptionText
event with the latest captions whenever a host speaks.
import VideoSDKRTC
extension LiveStreamViewController: MeetingEventListener {
// 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")
}
}
// Listen for transcription text event
func onTranscriptionText(_ data: TranscriptionText) {
print("transcription text: ", data.text)
print("participant name", data.participantName)
}
}
API Reference​
The API references for all the methods utilized in this guide are provided below.
Got a Question? Ask us on discord