Skip to main content
Version: 0.1.x

Realtime Transcription - Android

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.

Moreover, VideoSDK offers flexibility in configuring real-time transcription, allowing you to set up webhooks for this purpose.

Integrating Realtime Transcription Feature

alt text

The above image represents,

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

  2. Resource Acquisition: VideoSDK server requests necessary resources from transcription service.

    • If the request is denied, the server sends a transcription-failed event to the SDK Client.
    • If the request is successful, the server sends a onTranscriptionStateChanged event with status TRANSCRIPTION_STARTED to the client, indicating that transcription has begun.
  3. Transcription Data: As transcription progresses, the client receives onTranscriptionText event with data such as the text itself, participant ID, and timestamp.

  4. Stop Transcription: When the client decides to stop transcription, it informs the VideoSDK server to release resources.

    • The server then sends a onTranscriptionStateChanged event with status TRANSCRIPTION_STOPPED to confirm that transcription has ended and resources are released.

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.
// Webhook URL where, webhooks are received
val webhookUrl = "YOUR_WEBHOOK_URL"

// Realtime Transcription Configuration
val summaryConfig = SummaryConfig(
true,
"Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
)
val transcription = TranscriptionConfig(
webhookUrl,
summaryConfig
)

Step 2: Listen for the transcription events

  • Here, we configure the callback methods for transcription events.
private val meetingEventListener: MeetingEventListener = object : MeetingEventListener() {
override fun onTranscriptionStateChanged(data: JSONObject) {
try {
val status = data.getString("status")
val id = data.getString("id")
when (status) {
TranscriptionState.TRANSCRIPTION_STARTING.name -> Log.d("onTranscriptionStateChanged", "Realtime Transcription is starting, ID: $id")
TranscriptionState.TRANSCRIPTION_STARTED.name -> Log.d("onTranscriptionStateChanged", "Realtime Transcription is started, ID: $id")
TranscriptionState.TRANSCRIPTION_STOPPING.name -> Log.d("onTranscriptionStateChanged", "Realtime Transcription is stopping, ID: $id")
TranscriptionState.TRANSCRIPTION_STOPPED.name -> Log.d("onTranscriptionStateChanged", "Realtime Transcription is stopped, ID: $id")
else -> Log.d("onTranscriptionStateChanged", "Unknown transcription state: $status, ID: $id")
}
} catch (e: JSONException) {
Log.e("onTranscriptionStateChanged", "Error parsing transcription state", e)
}
}

override fun onTranscriptionText(data: TranscriptionText) {
val participantId: String = data.participantId
val participantName: String = data.participantName
val text: String = data.text
val timestamp: Int = data.timestamp
val type: String = data.type

Log.d("onTranscriptionText", "$participantName: $text $timestamp")
}
}

override fun onCreate(savedInstanceState: Bundle?) {
//...

// add listener to meeting
meeting!!.addEventListener(meetingEventListener)
}

Step 3: Start realtime transcription

  • Initiate the realtime transcription using the startTranscription() method.
fun startRealtimeTranscription() {
// Webhook URL where, webhooks are received
val webhookUrl = "YOUR_WEBHOOK_URL"

// Realtime Transcription Configuration
val summaryConfig = SummaryConfig(
true,
"Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
)
val transcription = TranscriptionConfig(
webhookUrl,
summaryConfig
)

meeting!!.startTranscription(transcription)
}

Step 4: Stop realtime transcription

  • Terminate the realtime transcription using the stopTranscription() method.
fun stopRealtimeTranscription() {
meeting!!.stopTranscription()
}
important

You can access a summary of your realtime transcription using the Fetch Realtime Transcription API.

Example

  • The following code snippet allows you to start and stop realtime transcription with just a click. When you click the "Start Realtime Transcription" button, it begins realtime transcription. Clicking the "Stop Realtime Transcription" button ends the realtime transcription.
import android.os.Bundle
import android.util.Log
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import org.json.JSONObject

class MeetingActivity : AppCompatActivity() {
private lateinit var meeting: Meeting

// add meetingEventListener to handle transcription events
private val meetingEventListener = object : MeetingEventListener {
override fun onTranscriptionStateChanged(data: JSONObject) {
val status = data.getString("status")
Log.d("MeetingActivity", "Transcription status: $status")
}

override fun onTranscriptionText(data: TranscriptionText) {
val participantId = data.participantId
val participantName = data.participantName
val text = data.text
val timestamp = data.timestamp
val type = data.type

Log.d("MeetingActivity", "$participantName: $text $timestamp")
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_meeting)

//initialize a meeting
//...

val startButton: Button = findViewById(R.id.startTranscriptionButton)
val stopButton: Button = findViewById(R.id.stopTranscriptionButton)

startButton.setOnClickListener { startRealtimeTranscription() }
stopButton.setOnClickListener { stopRealtimeTranscription() }

// add listener to meeting
meeting!!.setEventListener(meetingEventListener)
}

private fun startRealtimeTranscription() {
// Configuration for realtime transcription
val summaryConfig = SummaryConfig(
true,
"Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
)
val transcriptionConfig = TranscriptionConfig(
null,
summaryConfig
)

// Call to start transcription with the specified configuration
meeting!!.startTranscription(transcriptionConfig)
}

private fun stopRealtimeTranscription() {
// Call to stop transcription
meeting!!.stopTranscription()
}
}

API Reference

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

Got a Question? Ask us on discord