Skip to content

Commit

Permalink
fix(transcriptions) obey skipInterimTranscriptions for chunk events
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Feb 1, 2024
1 parent 2be8377 commit ad6554a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions react/features/subtitles/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ function _endpointMessageReceived({ dispatch, getState }: IStore, next: Function
const language
= state['features/base/conference'].conference
?.getLocalParticipantProperty(P_NAME_TRANSLATION_LANGUAGE);
const { skipInterimTranscriptions } = state['features/base/config'].testing ?? {};

const transcriptMessageID = json.message_id;
const { name, id, avatar_url: avatarUrl } = json.participant;
const participant = {
Expand All @@ -126,13 +128,23 @@ function _endpointMessageReceived({ dispatch, getState }: IStore, next: Function

const { text } = json.transcript[0];

// First, notify the external API, but only do so for final messages.
if (typeof APP !== 'undefined' && !json.is_interim) {
// First, notify the external API.
if (typeof APP !== 'undefined' && !(json.is_interim && skipInterimTranscriptions)) {
const txt: any = {};

if (!json.is_interim) {
txt.final = text;
} else if (json.stability > STABLE_TRANSCRIPTION_FACTOR) {
txt.stable = text;
} else {
txt.unstable = text;
}

APP.API.notifyTranscriptionChunkReceived({
messageID: transcriptMessageID,
final: text,
language: json.language,
participant
participant,
...txt
});
}

Expand All @@ -141,8 +153,6 @@ function _endpointMessageReceived({ dispatch, getState }: IStore, next: Function
return next(action);
}

const { skipInterimTranscriptions } = state['features/base/config'].testing ?? {};

if (json.is_interim && skipInterimTranscriptions) {
return next(action);
}
Expand Down

0 comments on commit ad6554a

Please sign in to comment.