diff --git a/bigbluebutton-html5/imports/api/audio-captions/server/methods/updateTranscript.js b/bigbluebutton-html5/imports/api/audio-captions/server/methods/updateTranscript.js index 3b1b7bf68c..a00802a17e 100644 --- a/bigbluebutton-html5/imports/api/audio-captions/server/methods/updateTranscript.js +++ b/bigbluebutton-html5/imports/api/audio-captions/server/methods/updateTranscript.js @@ -3,7 +3,7 @@ import RedisPubSub from '/imports/startup/server/redis'; import { extractCredentials } from '/imports/api/common/server/helpers'; import Logger from '/imports/startup/server/logger'; -export default function updateTranscript(transcriptId, start, end, text, transcript, locale) { +export default function updateTranscript(transcriptId, start, end, text, transcript, locale, isFinal) { try { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; @@ -19,6 +19,7 @@ export default function updateTranscript(transcriptId, start, end, text, transcr check(text, String); check(transcript, String); check(locale, String); + check(isFinal, Boolean); // Ignore irrelevant updates if (start !== -1 && end !== -1) { @@ -29,6 +30,7 @@ export default function updateTranscript(transcriptId, start, end, text, transcr text, transcript, locale, + result: isFinal, }; RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); diff --git a/bigbluebutton-html5/imports/ui/components/audio/captions/speech/service.js b/bigbluebutton-html5/imports/ui/components/audio/captions/speech/service.js index c437e61c3d..dbfc908122 100644 --- a/bigbluebutton-html5/imports/ui/components/audio/captions/speech/service.js +++ b/bigbluebutton-html5/imports/ui/components/audio/captions/speech/service.js @@ -81,7 +81,7 @@ const initSpeechRecognition = () => { let prevId = ''; let prevTranscript = ''; -const updateTranscript = (id, transcript, locale) => { +const updateTranscript = (id, transcript, locale, isFinal) => { // If it's a new sentence if (id !== prevId) { prevId = id; @@ -102,7 +102,7 @@ const updateTranscript = (id, transcript, locale) => { // Stores current transcript as previous prevTranscript = transcript; - makeCall('updateTranscript', id, start, end, text, transcript, locale); + makeCall('updateTranscript', id, start, end, text, transcript, locale, isFinal); }; const throttledTranscriptUpdate = throttle(updateTranscript, THROTTLE_TIMEOUT, { @@ -111,12 +111,12 @@ const throttledTranscriptUpdate = throttle(updateTranscript, THROTTLE_TIMEOUT, { }); const updateInterimTranscript = (id, transcript, locale) => { - throttledTranscriptUpdate(id, transcript, locale); + throttledTranscriptUpdate(id, transcript, locale, false); }; const updateFinalTranscript = (id, transcript, locale) => { throttledTranscriptUpdate.cancel(); - updateTranscript(id, transcript, locale); + updateTranscript(id, transcript, locale, true); }; const getSpeechLocale = (userId = Auth.userID) => { @@ -133,7 +133,7 @@ const isLocaleValid = (locale) => LANGUAGES.includes(locale); const isEnabled = () => isLiveTranscriptionEnabled(); -const isWebSpeechApi = () => PROVIDER === 'webspeech' && hasSpeechRecognitionSupport() && hasSpeechLocale(); +const isWebSpeechApi = () => PROVIDER === 'webspeech'; const isVosk = () => PROVIDER === 'vosk'; @@ -141,7 +141,7 @@ const isWhispering = () => PROVIDER === 'whisper'; const isDeepSpeech = () => PROVIDER === 'deepSpeech' -const isActive = () => isEnabled() && (isWebSpeechApi() || isVosk() || isWhispering() || isDeepSpeech()); +const isActive = () => isEnabled() && ((isWebSpeechApi() && hasSpeechLocale()) || isVosk() || isWhispering() || isDeepSpeech()); const getStatus = () => { const active = isActive();