Available since v5.0.4 — transcription and closed captions require CometChat Calls SDK v5.0.4 or later for iOS. See Setup to install or upgrade.
TranscriptsRequest.
How It Works
Transcription and closed captions are two related but separate things:
Starting transcription is a prerequisite for captions — turning captions on without an active transcription shows nothing.
Starting Transcription
Auto-Start Transcription
Configure transcription to start automatically when the session begins:- Swift
- Objective-C
false
Manual Transcription Control
Start Transcription
Begin transcribing during an active call:- Swift
- Objective-C
Stop Transcription
Stop the current transcription. Any captions currently on screen are cleared:- Swift
- Objective-C
Built-in UI Controls
Both transcription controls live in the control panel’s More menu, and both are hidden by default.Transcription Menu Item
To show the transcription item:- Swift
- Objective-C
true
The item toggles between Start Transcription and Stop Transcription based on the current state.
Closed Caption Menu Item
To show the closed-caption item:- Swift
- Objective-C
true
The item toggles between Show Captions and Hide Captions.
Captions are off by default, so the overlay appears only after the user turns them on and transcription is running for the session. Turning captions on before transcription starts shows nothing until the transcript begins arriving.
Caption Language
Method:setCaptionLanguage(_ captionLanguage: String)
Sets the language used for transcription and captions.
- Swift
- Objective-C
en-US
Supported Language Codes
Supported Language Codes
Retrieving Transcripts
After a call, useTranscriptsRequest to list the transcript artifacts for a session. Each record is a pointer to a downloadable transcript file, not the transcript text itself.
The SDK must be initialized with
CometChatCalls.init() and a user must be logged in. The auth token is read from the logged-in user at fetch time, so it automatically tracks re-logins — there is no set(authToken:) on this builder.Building a Request
- Swift
- Objective-C
Callbacks are delivered on the main queue, so it is safe to update UI directly from them.
Paginating
ATranscriptsRequest is a stateful cursor. Create one per session ID and drive it with fetchNext and fetchPrevious:
- Swift
- Objective-C
fetchNextdelivers the next page, or an empty array when there are no more pages. A session with no transcripts delivers an empty array.fetchPreviousdelivers the previous page, or an empty array when already on the first page. It never requests a page below1.- The cursor is committed only from a successful response, so a failed fetch can simply be retried.
- Only one fetch may be in flight per request instance. Calling
fetchNextorfetchPreviouswhile another is pending fails withERROR_REQUEST_IN_PROGRESS; the original call is unaffected and still completes.
Transcript Properties
The server omits keys whose value is empty, so sparse records are normal and should not be treated as an error. Missing string fields arrive as
"" and missing numbers as 0. A single entry that fails to parse is skipped rather than failing the whole page.Reading the Transcript Content
transcriptUrl points at the transcript file. Fetch it yourself to read the actual utterances:
- Swift
- Objective-C
Error Handling
Failures are delivered to theonError closure as a CometChatCallException carrying an errorCode:
Transcripts in Call Logs
Call logs can be filtered to transcribed calls, which also attaches each call’s transcripts to the log:- Swift
- Objective-C
transcriptions is an empty array when the server omitted transcripts, so it never needs a nil check. Passing false leaves the list unfiltered, exactly as if the filter had never been set — and the server then omits the transcripts.
Complete Example
- Swift
- Objective-C