Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(external_api) add event with transcription chunks

Saúl Ibarra Corretgéc530bdd10782
diff --git a/modules/API/API.js b/modules/API/API.js
index b547c36864..62200fcbb4 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -1987,6 +1987,20 @@ class API {
});
}
+ /**
+ * Notify external application (if API is enabled) that the user received
+ * a transcription chunk.
+ *
+ * @param {Object} data - The event data.
+ * @returns {void}
+ */
+ notifyTranscriptionChunkReceived(data) {
+ this._sendEvent({
+ name: 'transcription-chunk-received',
+ data
+ });
+ }
+
/**
* Notify external application (if API is enabled) whether the used browser is supported or not.
*
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index a9de1e2eef..8fac64b1d1 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -160,6 +160,7 @@ const events = {
'suspend-detected': 'suspendDetected',
'tile-view-changed': 'tileViewChanged',
'toolbar-button-clicked': 'toolbarButtonClicked',
+ 'transcription-chunk-received': 'transcriptionChunkReceived',
'whiteboard-status-changed': 'whiteboardStatusChanged'
};
diff --git a/react/features/subtitles/middleware.ts b/react/features/subtitles/middleware.ts
index 7c58bb0ab6..f62969f876 100644
--- a/react/features/subtitles/middleware.ts
+++ b/react/features/subtitles/middleware.ts
@@ -153,10 +153,15 @@ function _endpointMessageReceived({ dispatch, getState }: IStore, next: Function
newTranscriptMessage.unstable = text;
}
- dispatch(
- updateTranscriptMessage(
- transcriptMessageID,
- newTranscriptMessage));
+ dispatch(updateTranscriptMessage(transcriptMessageID, newTranscriptMessage));
+
+ // Notify the external API too.
+ if (typeof APP !== 'undefined') {
+ APP.API.notifyTranscriptionChunkReceived({
+ messageID: transcriptMessageID,
+ ...newTranscriptMessage
+ });
+ }
}
} catch (error) {
logger.error('Error occurred while updating transcriptions\n', error);