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(translation) Support realtime translations in conferences (#17538)

Jaya Allamsettycb7bf9424807
diff --git a/lang/main.json b/lang/main.json
index 9d80c7ab09..ffd61532ac 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -42,6 +42,14 @@
"audioOnly": {
"audioOnly": "Low bandwidth"
},
+ "audioTranslation": {
+ "disabledForRoom": "Audio translation has been turned off for this meeting.",
+ "errorForbidden": "You don't have permission to use audio translation.",
+ "errorGeneric": "Couldn't enable audio translation. Please try again.",
+ "errorLimitReached": "Couldn't translate everyone at once. Turn on translation for individual participants instead.",
+ "errorRoomDisabled": "Audio translation is turned off for this meeting. Enable it in Moderator settings.",
+ "errorSpeakerUnavailable": "Can't translate this participant — they're no longer in the meeting."
+ },
"bandwidthSettings": {
"assumedBandwidthBps": "e.g. 10000000 for 10 Mbps",
"assumedBandwidthBpsWarning": "Higher values might cause network issues.",
@@ -1218,6 +1226,7 @@
},
"settings": {
"audio": "Audio",
+ "audioTranslation": "Enable audio translation",
"buttonLabel": "Settings",
"calendar": {
"about": "The {{appName}} calendar integration is used to securely access your calendar so it can read upcoming events.",
@@ -1347,6 +1356,7 @@
"Settings": "Open settings",
"audioOnly": "Toggle audio only",
"audioRoute": "Select the sound device",
+ "audioTranslation": "Translate audio",
"boo": "Boo",
"breakoutRooms": "Breakout rooms",
"callQuality": "Manage video quality",
@@ -1455,6 +1465,8 @@
"audioOnlyOn": "Enable low bandwidth mode",
"audioRoute": "Select the sound device",
"audioSettings": "Audio settings",
+ "audioTranslation": "Translate audio",
+ "audioTranslationOff": "Off",
"authenticate": "Authenticate",
"boo": "Boo",
"callQuality": "Manage video quality",
diff --git a/react/features/app/middlewares.any.ts b/react/features/app/middlewares.any.ts
index 63ebb4815b..33844f65ce 100644
--- a/react/features/app/middlewares.any.ts
+++ b/react/features/app/middlewares.any.ts
@@ -1,4 +1,5 @@
import '../analytics/middleware';
+import '../audio-translation/middleware';
import '../authentication/middleware';
import '../av-moderation/middleware';
import '../base/conference/middleware';
diff --git a/react/features/app/reducers.any.ts b/react/features/app/reducers.any.ts
index 28e22b3088..d10b5f23eb 100644
--- a/react/features/app/reducers.any.ts
+++ b/react/features/app/reducers.any.ts
@@ -1,4 +1,5 @@
import '../analytics/reducer';
+import '../audio-translation/reducer';
import '../authentication/reducer';
import '../av-moderation/reducer';
import '../base/app/reducer';
diff --git a/react/features/app/types.ts b/react/features/app/types.ts
index f4f2f6de61..74ab6620c6 100644
--- a/react/features/app/types.ts
+++ b/react/features/app/types.ts
@@ -2,6 +2,7 @@ import { AnyAction } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { IAnalyticsState } from '../analytics/reducer';
+import { IAudioTranslationState } from '../audio-translation/reducer';
import { IAuthenticationState } from '../authentication/reducer';
import { IAVModerationState } from '../av-moderation/reducer';
import { IAppState } from '../base/app/reducer';
@@ -93,6 +94,7 @@ export interface IStore {
export interface IReduxState {
'features/analytics': IAnalyticsState;
+ 'features/audio-translation': IAudioTranslationState;
'features/authentication': IAuthenticationState;
'features/av-moderation': IAVModerationState;
'features/base/app': IAppState;
diff --git a/react/features/audio-translation/actionTypes.ts b/react/features/audio-translation/actionTypes.ts
new file mode 100644
index 0000000000..94b64a1975
--- /dev/null
+++ b/react/features/audio-translation/actionTypes.ts
@@ -0,0 +1,18 @@
+/**
+ * The type of (redux) action which clears all AI audio translation state (the default
+ * language and every per-participant override), e.g. after the bridge rejects a request.
+ */
+export const CLEAR_AUDIO_TRANSLATION = 'CLEAR_AUDIO_TRANSLATION';
+
+/**
+ * The type of (redux) action which sets the default AI audio translation target
+ * language for every speaker, or null when translation is turned off.
+ */
+export const SET_AUDIO_TRANSLATION_LANGUAGE = 'SET_AUDIO_TRANSLATION_LANGUAGE';
+
+/**
+ * The type of (redux) action which sets the AI audio translation target language
+ * for a single participant (overriding the default), or null to disable it for
+ * that participant.
+ */
+export const SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE = 'SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE';
diff --git a/react/features/audio-translation/actions.ts b/react/features/audio-translation/actions.ts
new file mode 100644
index 0000000000..e0dd9ac7af
--- /dev/null
+++ b/react/features/audio-translation/actions.ts
@@ -0,0 +1,60 @@
+import {
+ CLEAR_AUDIO_TRANSLATION,
+ SET_AUDIO_TRANSLATION_LANGUAGE,
+ SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE
+} from './actionTypes';
+
+/**
+ * Clears all AI audio translation state — the default language and every per-participant
+ * override. Used to reset the feature, e.g. when the bridge rejects a translation request.
+ *
+ * @returns {{
+ * type: string
+ * }}
+ */
+export function clearAudioTranslation() {
+ return {
+ type: CLEAR_AUDIO_TRANSLATION
+ };
+}
+
+/**
+ * Sets the default target language for AI audio translation. The bridge is asked
+ * to translate every remote speaker into this language and the local endpoint
+ * subscribes to the resulting translated sources (in addition to the originals,
+ * which are ducked during playback). Pass null to turn translation off.
+ *
+ * @param {string|null} language - The 2-letter ISO target language code, or null
+ * to disable translation.
+ * @returns {{
+ * language: (string | null),
+ * type: string
+ * }}
+ */
+export function setAudioTranslationLanguage(language: string | null) {
+ return {
+ type: SET_AUDIO_TRANSLATION_LANGUAGE,
+ language
+ };
+}
+
+/**
+ * Sets the AI audio translation target language for a single participant,
+ * overriding the default. Pass null to disable translation for that participant.
+ *
+ * @param {string} participantId - The participant whose translation language to set.
+ * @param {string|null} language - The 2-letter ISO target language code, or null
+ * to disable translation for this participant.
+ * @returns {{
+ * language: (string | null),
+ * participantId: string,
+ * type: string
+ * }}
+ */
+export function setParticipantAudioTranslationLanguage(participantId: string, language: string | null) {
+ return {
+ type: SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE,
+ participantId,
+ language
+ };
+}
diff --git a/react/features/audio-translation/components/web/AudioTranslationButton.tsx b/react/features/audio-translation/components/web/AudioTranslationButton.tsx
new file mode 100644
index 0000000000..dd8e42f61e
--- /dev/null
+++ b/react/features/audio-translation/components/web/AudioTranslationButton.tsx
@@ -0,0 +1,61 @@
+import { connect } from 'react-redux';
+
+import { IReduxState } from '../../../app/types';
+import { openDialog } from '../../../base/dialog/actions';
+import { translate } from '../../../base/i18n/functions';
+import { IconTranslate } from '../../../base/icons/svg';
+import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
+
+import AudioTranslationDialog from './AudioTranslationDialog';
+
+interface IProps extends AbstractButtonProps {
+
+ /**
+ * The target language remote audio is currently translated into, or null.
+ */
+ _language: string | null;
+}
+
+/**
+ * A toolbar button that opens the AI audio-translation language selector.
+ */
+class AudioTranslationButton extends AbstractButton<IProps> {
+ override accessibilityLabel = 'toolbar.accessibilityLabel.audioTranslation';
+ override icon = IconTranslate;
+ override label = 'toolbar.audioTranslation';
+ override tooltip = 'toolbar.audioTranslation';
+
+ /**
+ * Handles clicking the button by opening the language selector dialog.
+ *
+ * @override
+ * @returns {void}
+ */
+ override _handleClick() {
+ this.props.dispatch(openDialog('AudioTranslationDialog', AudioTranslationDialog));
+ }
+
+ /**
+ * Indicates whether this button is in the toggled (translation-on) state.
+ *
+ * @override
+ * @returns {boolean}
+ */
+ override _isToggled() {
+ return Boolean(this.props._language);
+ }
+}
+
+/**
+ * Maps (parts of) the redux state to the button's props.
+ *
+ * @param {IReduxState} state - The redux state.
+ * @returns {Object}
+ */
+function _mapStateToProps(state: IReduxState) {
+ return {
+ _language: state['features/audio-translation'].language
+ };
+}
+
+export default translate(connect(_mapStateToProps)(AudioTranslationButton));
diff --git a/react/features/audio-translation/components/web/AudioTranslationDialog.tsx b/react/features/audio-translation/components/web/AudioTranslationDialog.tsx
new file mode 100644
index 0000000000..8b2ce47fd5
--- /dev/null
+++ b/react/features/audio-translation/components/web/AudioTranslationDialog.tsx
@@ -0,0 +1,89 @@
+import React, { useCallback } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+import { makeStyles } from 'tss-react/mui';
+
+import { IReduxState } from '../../../app/types';
+import { hideDialog } from '../../../base/dialog/actions';
+import { translate } from '../../../base/i18n/functions';
+import Dialog from '../../../base/ui/components/web/Dialog';
+import { setAudioTranslationLanguage, setParticipantAudioTranslationLanguage } from '../../actions';
+import { SUPPORTED_TRANSLATION_LANGUAGES } from '../../constants';
+
+import AudioTranslationLanguageItem from './AudioTranslationLanguageItem';
+
+interface IProps {
+
+ /**
+ * When set, the dialog targets this single participant (overriding the default); otherwise it sets the
+ * default language for every speaker.
+ */
+ participantId?: string;
+
+ /**
+ * Invoked to obtain translated strings.
+ */
+ t: (key: string) => string;
+}
+
+const useStyles = makeStyles()(() => {
+ return {
+ list: {
+ display: 'flex',
+ flexDirection: 'column'
+ }
+ };
+});
+
+/**
+ * A dialog for selecting the AI audio-translation target language (or off).
+ *
+ * @param {IProps} props - The component's props.
+ * @returns {ReactElement}
+ */
+const AudioTranslationDialog = ({ participantId, t }: IProps) => {
+ const dispatch = useDispatch();
+ const { classes: styles } = useStyles();
+ const defaultLanguage = useSelector((state: IReduxState) => state['features/audio-translation'].language);
+ const participantLanguages
+ = useSelector((state: IReduxState) => state['features/audio-translation'].participantLanguages);
+
+ // Highlight the effective language for the target: the per-participant override if one is set, else the
+ // default. (For the conference-wide dialog there is no participantId, so this is just the default.)
+ const language = participantId && participantId in participantLanguages
+ ? participantLanguages[participantId]
+ : defaultLanguage;
+
+ const onSelect = useCallback((code: string | null) => {
+ if (participantId) {
+ dispatch(setParticipantAudioTranslationLanguage(participantId, code));
+ } else {
+ dispatch(setAudioTranslationLanguage(code));
+ }
+ dispatch(hideDialog());
+ }, [ dispatch, participantId ]);
+
+ return (
+ <Dialog
+ cancel = {{ hidden: true }}
+ ok = {{ hidden: true }}
+ titleKey = 'toolbar.audioTranslation'>
+ <div className = { styles.list }>
+ <AudioTranslationLanguageItem
+ code = { null }
+ label = { t('toolbar.audioTranslationOff') }
+ onSelect = { onSelect }
+ selected = { !language } />
+ { SUPPORTED_TRANSLATION_LANGUAGES.map(({ code, label }) => (
+ <AudioTranslationLanguageItem
+ code = { code }
+ key = { code }
+ label = { label }
+ onSelect = { onSelect }
+ selected = { language === code } />
+ )) }
+ </div>
+ </Dialog>
+ );
+};
+
+export default translate(AudioTranslationDialog);
diff --git a/react/features/audio-translation/components/web/AudioTranslationLanguageItem.tsx b/react/features/audio-translation/components/web/AudioTranslationLanguageItem.tsx
new file mode 100644
index 0000000000..a21fa9f246
--- /dev/null
+++ b/react/features/audio-translation/components/web/AudioTranslationLanguageItem.tsx
@@ -0,0 +1,71 @@
+import React, { useCallback } from 'react';
+import { makeStyles } from 'tss-react/mui';
+
+interface IProps {
+
+ /**
+ * The target language code, or null for the "off" option.
+ */
+ code: string | null;
+
+ /**
+ * The label to display.
+ */
+ label: string;
+
+ /**
+ * Called with this item's code when it is selected.
+ */
+ onSelect: (code: string | null) => void;
+
+ /**
+ * Whether this item is the currently-selected option.
+ */
+ selected: boolean;
+}
+
+const useStyles = makeStyles()(theme => {
+ return {
+ item: {
+ display: 'flex',
+ alignItems: 'center',
+ padding: '12px 16px',
+ cursor: 'pointer',
+ border: 'none',
+ background: 'none',
+ textAlign: 'left',
+ fontSize: '0.875rem',
+ color: theme.palette.text01,
+ borderRadius: `${theme.shape.borderRadius}px`,
+ '&:hover': {
+ backgroundColor: theme.palette.ui02
+ }
+ },
+ selected: {
+ fontWeight: 700,
+ color: theme.palette.link01
+ }
+ };
+});
+
+/**
+ * A single selectable language row in the audio-translation dialog.
+ *
+ * @param {IProps} props - The component's props.
+ * @returns {ReactElement}
+ */
+const AudioTranslationLanguageItem = ({ code, label, onSelect, selected }: IProps) => {
+ const { classes: styles, cx } = useStyles();
+ const onClick = useCallback(() => onSelect(code), [ code, onSelect ]);
+
+ return (
+ <button
+ className = { cx(styles.item, selected && styles.selected) }
+ onClick = { onClick }
+ type = 'button'>
+ { label }
+ </button>
+ );
+};
+
+export default AudioTranslationLanguageItem;
diff --git a/react/features/audio-translation/constants.ts b/react/features/audio-translation/constants.ts
new file mode 100644
index 0000000000..2c0e50c4f9
--- /dev/null
+++ b/react/features/audio-translation/constants.ts
@@ -0,0 +1,28 @@
+/**
+ * Supported AI audio-translation target languages: ISO code + picker label.
+ */
+export const SUPPORTED_TRANSLATION_LANGUAGES: Array<{ code: string; label: string; }> = [
+ { code: 'en', label: 'English' },
+ { code: 'es', label: 'Español' },
+ { code: 'pt', label: 'Português' },
+ { code: 'fr', label: 'Français' },
+ { code: 'de', label: 'Deutsch' },
+ { code: 'it', label: 'Italiano' },
+ { code: 'ru', label: 'Русский' },
+ { code: 'zh', label: '中文' },
+ { code: 'ja', label: '日本語' },
+ { code: 'ko', label: '한국어' },
+ { code: 'hi', label: 'हिन्दी' },
+ { code: 'id', label: 'Bahasa Indonesia' },
+ { code: 'vi', label: 'Tiếng Việt' }
+];
+
+/**
+ * Full volume (0..1) a speaker's original audio is restored to once it is no longer ducked.
+ */
+export const DEFAULT_ORIGINAL_VOLUME = 1;
+
+/**
+ * Volume (0..1) a speaker's original audio is ducked to while its translation plays.
+ */
+export const DUCKED_ORIGINAL_VOLUME = 0.15;
diff --git a/react/features/audio-translation/functions.ts b/react/features/audio-translation/functions.ts
new file mode 100644
index 0000000000..9fd41f9f61
--- /dev/null
+++ b/react/features/audio-translation/functions.ts
@@ -0,0 +1,80 @@
+import { IReduxState } from '../app/types';
+import { MEET_FEATURES } from '../base/jwt/constants';
+import { isJwtFeatureEnabled } from '../base/jwt/functions';
+import { isLocalParticipantModerator } from '../base/participants/functions';
+import { ITrack } from '../base/tracks/types';
+
+/**
+ * Whether audio translation is enabled for the room. Driven by the {@code audioTranslation} RoomMetadata flag,
+ * which a moderator can toggle; absent or any value other than an explicit {@code false} means enabled.
+ *
+ * @param {IReduxState} state - The redux state.
+ * @returns {boolean}
+ */
+export function isAudioTranslationRoomEnabled(state: IReduxState): boolean {
+ return state['features/base/conference'].metadata?.audioTranslation?.enabled !== false;
+}
+
+/**
+ * Whether the local user may manage audio translation for the room (i.e. toggle the room-wide flag). Mirrors the
+ * prosody {@code live-translation} permission: the token's explicit value wins, otherwise moderators have it.
+ *
+ * @param {IReduxState} state - The redux state.
+ * @returns {boolean}
+ */
+export function canManageAudioTranslation(state: IReduxState): boolean {
+ return isJwtFeatureEnabled(state, MEET_FEATURES.LIVE_TRANSLATION, isLocalParticipantModerator(state));
+}
+
+/**
+ * Whether the audio-translation UI should be available to the local user: the feature must be deployed
+ * ({@code config.audioTranslation.enabled}) and either the user can manage it or it is enabled for the room.
+ *
+ * @param {IReduxState} state - The redux state.
+ * @returns {boolean}
+ */
+export function isAudioTranslationAvailable(state: IReduxState): boolean {
+ if (!state['features/base/config'].audioTranslation?.enabled) {
+ return false;
+ }
+
+ return canManageAudioTranslation(state) || isAudioTranslationRoomEnabled(state);
+}
+
+/**
+ * Memoization for {@link getTranslatedSourceNames}: the tracks array is replaced on every tracks update, so
+ * the set is rebuilt only when that reference changes and is shared by all callers in between.
+ */
+let _lastTracks: ITrack[] | undefined;
+let _lastTranslatedSourceNames = new Set<string>();
+
+/**
+ * Returns the set of translated audio source names currently present in the conference. Translated sources
+ * follow the {@code <sourceName>.<language>} convention, so any source name containing a dot is one. Memoized
+ * on the tracks array reference, letting callers do an O(1) lookup instead of scanning every track.
+ *
+ * @param {IReduxState} state - The redux state.
+ * @returns {Set<string>} The translated source names present in the conference.
+ */
+export function getTranslatedSourceNames(state: IReduxState): Set<string> {
+ const tracks = state['features/base/tracks'];
+
+ if (tracks === _lastTracks) {
+ return _lastTranslatedSourceNames;
+ }
+
+ const translated = new Set<string>();
+
+ for (const track of tracks) {
+ const sourceName = track.jitsiTrack?.getSourceName?.();
+
+ if (typeof sourceName === 'string' && sourceName.includes('.')) {
+ translated.add(sourceName);
+ }
+ }
+
+ _lastTracks = tracks;
+ _lastTranslatedSourceNames = translated;
+
+ return translated;
+}
diff --git a/react/features/audio-translation/hooks.web.ts b/react/features/audio-translation/hooks.web.ts
new file mode 100644
index 0000000000..56a54692b8
--- /dev/null
+++ b/react/features/audio-translation/hooks.web.ts
@@ -0,0 +1,28 @@
+import { useSelector } from 'react-redux';
+
+import AudioTranslationButton from './components/web/AudioTranslationButton';
+import { isAudioTranslationAvailable } from './functions';
+
+const audioTranslation = {
+ key: 'audiotranslation',
+ Content: AudioTranslationButton,
+ group: 2
+};
+
+/**
+ * A hook that returns the audio-translation toolbar button when the feature is available to the local user,
+ * and undefined otherwise. Audio translation requires the bridge translation backend (opt-in via
+ * config.audioTranslation.enabled), is hidden when a moderator has disabled it for the room, and is always
+ * shown to those who can manage it.
+ *
+ * @returns {Object | undefined}
+ */
+export function useAudioTranslationButton() {
+ const available = useSelector(isAudioTranslationAvailable);
+
+ if (!available) {
+ return undefined;
+ }
+
+ return audioTranslation;
+}
diff --git a/react/features/audio-translation/logger.ts b/react/features/audio-translation/logger.ts
new file mode 100644
index 0000000000..5ced23e9e2
--- /dev/null
+++ b/react/features/audio-translation/logger.ts
@@ -0,0 +1,3 @@
+import { getLogger } from '../base/logging/functions';
+
+export default getLogger('app:audio-translation');
diff --git a/react/features/audio-translation/middleware.ts b/react/features/audio-translation/middleware.ts
new file mode 100644
index 0000000000..7acc37a493
--- /dev/null
+++ b/react/features/audio-translation/middleware.ts
@@ -0,0 +1,135 @@
+import { JitsiAudioTranslationErrors, JitsiConferenceEvents } from '../base/lib-jitsi-meet';
+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
+import StateListenerRegistry from '../base/redux/StateListenerRegistry';
+import { showErrorNotification, showNotification } from '../notifications/actions';
+import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
+
+import {
+ CLEAR_AUDIO_TRANSLATION,
+ SET_AUDIO_TRANSLATION_LANGUAGE,
+ SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE
+} from './actionTypes';
+import { clearAudioTranslation, setParticipantAudioTranslationLanguage } from './actions';
+import { isAudioTranslationRoomEnabled } from './functions';
+import logger from './logger';
+
+/**
+ * Maps an audio-translation component error condition to a notification message key. Unmapped conditions
+ * fall back to {@link DEFAULT_ERROR_KEY}.
+ */
+const ERROR_NOTIFICATION_KEYS: { [condition: string]: string; } = {
+ [JitsiAudioTranslationErrors.FORBIDDEN]: 'audioTranslation.errorForbidden',
+ [JitsiAudioTranslationErrors.SPEAKER_UNAVAILABLE]: 'audioTranslation.errorSpeakerUnavailable',
+ [JitsiAudioTranslationErrors.SUBSCRIPTION_LIMIT_REACHED]: 'audioTranslation.errorLimitReached'
+};
+
+const DEFAULT_ERROR_KEY = 'audioTranslation.errorGeneric';
+
+/**
+ * Middleware that drives the bridge-side translation when the local user changes
+ * the default or a per-participant audio-translation target language.
+ */
+MiddlewareRegistry.register(store => next => action => {
+ // Block enabling a translation language while a moderator has disabled the feature for the room. Managers
+ // keep the translation UI even when the room flag is off, and the bridge silently drops such requests, so
+ // surface a notification here instead. Disabling (language === null) is always allowed through.
+ if ((action.type === SET_AUDIO_TRANSLATION_LANGUAGE || action.type === SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE)
+ && action.language
+ && !isAudioTranslationRoomEnabled(store.getState())) {
+ store.dispatch(showErrorNotification({
+ titleKey: 'audioTranslation.errorRoomDisabled'
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
+
+ return;
+ }
+
+ const result = next(action);
+
+ switch (action.type) {
+ case CLEAR_AUDIO_TRANSLATION: {
+ const { conference } = store.getState()['features/base/conference'];
+
+ if (conference) {
+ logger.info('Clearing all audio translation state');
+ conference.clearTranslation();
+ }
+ break;
+ }
+ case SET_AUDIO_TRANSLATION_LANGUAGE: {
+ const { conference } = store.getState()['features/base/conference'];
+
+ if (conference) {
+ logger.info(`Setting audio translation language to ${action.language ?? 'off'}`);
+ conference.setReceiverTranslationLanguage(action.language);
+ }
+ break;
+ }
+ case SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE: {
+ const { conference } = store.getState()['features/base/conference'];
+
+ if (conference) {
+ logger.info(`Setting audio translation language for ${action.participantId} to ${action.language ?? 'off'}`);
+ conference.setParticipantTranslationLanguage(action.participantId, action.language);
+ }
+ break;
+ }
+ }
+
+ return result;
+});
+
+/**
+ * Surfaces audio-translation request failures reported by the bridge-side component: shows a notification
+ * describing the error condition and reverts the optimistic language selection for the affected speakers.
+ */
+StateListenerRegistry.register(
+ state => state['features/base/conference'].conference,
+ (conference, { dispatch }, previousConference) => {
+ if (!conference || previousConference) {
+ return;
+ }
+
+ conference.on(JitsiConferenceEvents.AUDIO_TRANSLATION_FAILED,
+ ({ endpointIds, error }: { endpointIds: string[]; error: string; }) => {
+ logger.warn(`Audio translation request failed: ${error} for [${endpointIds.join(', ')}]`);
+
+ dispatch(showErrorNotification({
+ titleKey: ERROR_NOTIFICATION_KEYS[error] ?? DEFAULT_ERROR_KEY
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
+
+ if (error === JitsiAudioTranslationErrors.SUBSCRIPTION_LIMIT_REACHED) {
+ // Too many speakers translated at once — reset everything; the notification guides the
+ // user to enable translation per participant instead.
+ dispatch(clearAudioTranslation());
+
+ return;
+ }
+
+ // Otherwise undo the optimistic selection only for the speakers the failed request touched.
+ endpointIds.forEach(endpointId =>
+ dispatch(setParticipantAudioTranslationLanguage(endpointId, null)));
+ });
+ });
+
+/**
+ * When a moderator disables audio translation for the room, clear the local user's active translation and notify
+ * them. The room flag only blocks new requests on the bridge; it does not tear down active subscriptions. Clearing
+ * locally drops the synthetic-source Include subscription (so the bridge stops forwarding the translated audio) and
+ * un-ducks the original.
+ */
+StateListenerRegistry.register(
+ state => isAudioTranslationRoomEnabled(state),
+ (roomEnabled, { dispatch, getState }) => {
+ if (roomEnabled) {
+ return;
+ }
+
+ const { language, participantLanguages } = getState()['features/audio-translation'];
+
+ if (language || Object.keys(participantLanguages).length > 0) {
+ dispatch(clearAudioTranslation());
+ dispatch(showNotification({
+ titleKey: 'audioTranslation.disabledForRoom'
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
+ }
+ });
diff --git a/react/features/audio-translation/reducer.ts b/react/features/audio-translation/reducer.ts
new file mode 100644
index 0000000000..380920dabb
--- /dev/null
+++ b/react/features/audio-translation/reducer.ts
@@ -0,0 +1,53 @@
+import ReducerRegistry from '../base/redux/ReducerRegistry';
+
+import {
+ CLEAR_AUDIO_TRANSLATION,
+ SET_AUDIO_TRANSLATION_LANGUAGE,
+ SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE
+} from './actionTypes';
+
+/**
+ * The redux state of the audio-translation feature.
+ */
+export interface IAudioTranslationState {
+
+ /**
+ * The default target language remote audio is translated into, or null when off.
+ */
+ language: string | null;
+
+ /**
+ * Per-participant target-language overrides (participantId -> language, or null to disable for that
+ * participant). An entry present here takes precedence over {@link language}; an absent entry inherits it.
+ */
+ participantLanguages: { [participantId: string]: string | null; };
+}
+
+const DEFAULT_STATE: IAudioTranslationState = {
+ language: null,
+ participantLanguages: {}
+};
+
+ReducerRegistry.register<IAudioTranslationState>(
+ 'features/audio-translation',
+ (state = DEFAULT_STATE, action): IAudioTranslationState => {
+ switch (action.type) {
+ case CLEAR_AUDIO_TRANSLATION:
+ return DEFAULT_STATE;
+ case SET_AUDIO_TRANSLATION_LANGUAGE:
+ return {
+ ...state,
+ language: action.language
+ };
+ case SET_PARTICIPANT_AUDIO_TRANSLATION_LANGUAGE:
+ return {
+ ...state,
+ participantLanguages: {
+ ...state.participantLanguages,
+ [action.participantId]: action.language
+ }
+ };
+ default:
+ return state;
+ }
+ });
diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.ts
index 3160fe02d1..1cac0d3943 100644
--- a/react/features/base/conference/reducer.ts
+++ b/react/features/base/conference/reducer.ts
@@ -54,6 +54,9 @@ const DEFAULT_STATE = {
};
export interface IConferenceMetadata {
+ audioTranslation?: {
+ enabled?: boolean;
+ };
dialinEnabled?: boolean;
files: {
[fileId: string]: {
@@ -91,6 +94,7 @@ export interface IJitsiConference {
avModerationApprove: Function;
avModerationReject: Function;
callUUID?: string;
+ clearTranslation: () => void;
createVideoSIPGWSession: Function;
dial: Function;
disableAVModeration: Function;
@@ -110,6 +114,7 @@ export interface IJitsiConference {
getParticipantCount: Function;
getParticipants: Function;
getPolls: Function;
+ getReceiverTranslationLanguage: () => string | null;
getRole: Function;
getShortTermCredentials: Function;
getSpeakerStats: () => ISpeakerStats;
@@ -159,7 +164,9 @@ export interface IJitsiConference {
setIsSilent: Function;
setLocalParticipantProperty: Function;
setMediaEncryptionKey: Function;
+ setParticipantTranslationLanguage: (participantId: string, language: string | null) => void;
setReceiverConstraints: Function;
+ setReceiverTranslationLanguage: (language: string | null) => void;
setSenderVideoConstraint: Function;
setStartMutedPolicy: Function;
setSubject: Function;
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index 707b4256c0..d04453a886 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -217,6 +217,14 @@ export interface IConfig {
opusMaxAverageBitrate?: number | null;
stereo?: boolean;
};
+
+ /**
+ * Configuration for AI audio translation. Requires a deployment with the
+ * bridge translation backend; the toolbar control is only shown when enabled.
+ */
+ audioTranslation?: {
+ enabled?: boolean;
+ };
/**
* @deprecated Use `transcription.autoTranscribeOnRecord` instead.
*/
diff --git a/react/features/base/icons/svg/constants.ts b/react/features/base/icons/svg/constants.ts
index 4bee92532f..0afe35baf6 100644
--- a/react/features/base/icons/svg/constants.ts
+++ b/react/features/base/icons/svg/constants.ts
@@ -90,6 +90,7 @@ import { default as IconStop } from './stop.svg';
import { default as IconSubtitles } from './subtitles.svg';
import { default as IconTileView } from './tile-view.svg';
import { default as IconTranscription } from './transcription.svg';
+import { default as IconTranslate } from './translate.svg';
import { default as IconTrash } from './trash.svg';
import { default as IconUserDeleted } from './user-deleted.svg';
import { default as IconUser } from './user.svg';
@@ -185,6 +186,7 @@ export const DEFAULT_ICON: Record<string, any> = {
IconRaiseHand,
IconRecord,
IconTranscription,
+ IconTranslate,
IconRecordAccount,
IconRecordContact,
IconRecordLead,
diff --git a/react/features/base/icons/svg/index.ts b/react/features/base/icons/svg/index.ts
index 3c77e14355..1248459cae 100644
--- a/react/features/base/icons/svg/index.ts
+++ b/react/features/base/icons/svg/index.ts
@@ -75,6 +75,7 @@ const {
IconRaiseHand,
IconRecord,
IconTranscription,
+ IconTranslate,
IconRecordAccount,
IconRecordContact,
IconRecordLead,
@@ -196,6 +197,7 @@ export {
IconRaiseHand,
IconRecord,
IconTranscription,
+ IconTranslate,
IconRecordAccount,
IconRecordContact,
IconRecordLead,
diff --git a/react/features/base/icons/svg/translate.svg b/react/features/base/icons/svg/translate.svg
new file mode 100644
index 0000000000..b307296076
--- /dev/null
+++ b/react/features/base/icons/svg/translate.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" />
+</svg>
diff --git a/react/features/base/jwt/constants.ts b/react/features/base/jwt/constants.ts
index 4a9a263a5f..e87f550f81 100644
--- a/react/features/base/jwt/constants.ts
+++ b/react/features/base/jwt/constants.ts
@@ -11,6 +11,7 @@ export const MEET_FEATURES: Record<string, ParticipantFeaturesKey> = {
FLIP: 'flip',
INBOUND_CALL: 'inbound-call',
LIVESTREAMING: 'livestreaming',
+ LIVE_TRANSLATION: 'live-translation',
LOBBY: 'lobby',
MODERATION: 'moderation',
OUTBOUND_CALL: 'outbound-call',
diff --git a/react/features/base/lib-jitsi-meet/index.ts b/react/features/base/lib-jitsi-meet/index.ts
index 5fc216158c..1e5ea19341 100644
--- a/react/features/base/lib-jitsi-meet/index.ts
+++ b/react/features/base/lib-jitsi-meet/index.ts
@@ -8,6 +8,7 @@ export { JitsiMeetJS as default };
// not confirmed the theory.
export const analytics = JitsiMeetJS.analytics;
export const browser = JitsiMeetJS.util.browser;
+export const JitsiAudioTranslationErrors = JitsiMeetJS.errors.audioTranslation;
export const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
export const JitsiConferenceEvents = JitsiMeetJS.events.conference;
export const JitsiConnectionErrors = JitsiMeetJS.errors.connection;
diff --git a/react/features/base/media/components/web/AudioTrack.tsx b/react/features/base/media/components/web/AudioTrack.tsx
index 2617c863eb..8bf682a8e3 100644
--- a/react/features/base/media/components/web/AudioTrack.tsx
+++ b/react/features/base/media/components/web/AudioTrack.tsx
@@ -4,6 +4,8 @@ import { connect } from 'react-redux';
import { createAudioPlayErrorEvent, createAudioPlaySuccessEvent } from '../../../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../../../analytics/functions';
import { IReduxState } from '../../../../app/types';
+import { DEFAULT_ORIGINAL_VOLUME, DUCKED_ORIGINAL_VOLUME } from '../../../../audio-translation/constants';
+import { getTranslatedSourceNames } from '../../../../audio-translation/functions';
import { ITrack } from '../../../tracks/types';
import logger from '../../logger';
@@ -334,10 +336,43 @@ class AudioTrack extends Component<IProps> {
*/
function _mapStateToProps(state: IReduxState, ownProps: any) {
const { participantsVolume } = state['features/filmstrip'];
+ const { language: defaultLanguage, participantLanguages } = state['features/audio-translation'];
+ const audioTranslationEnabled = state['features/base/config'].audioTranslation?.enabled;
+
+ let _volume: number | boolean | undefined = participantsVolume[ownProps.participantId];
+
+ // Effective translation language for this speaker: the per-participant override if one is set (which
+ // may be null to disable), otherwise the conference-wide default. Turning translation off — globally
+ // or for this participant — clears this, so the original un-ducks (this selector re-runs on change).
+ const participantId: string | undefined = ownProps.participantId;
+ const effectiveLanguage = participantId && participantId in participantLanguages
+ ? participantLanguages[participantId]
+ : defaultLanguage;
+
+ // Duck a speaker's original only while its translated counterpart ({source}.{language}) is present.
+ const sourceName: string | undefined = ownProps.audioTrack?.jitsiTrack?.getSourceName?.();
+
+ let ducked = false;
+
+ if (effectiveLanguage && typeof sourceName === 'string' && !sourceName.endsWith(`.${effectiveLanguage}`)) {
+ const translatedSourceName = `${sourceName}.${effectiveLanguage}`;
+
+ if (getTranslatedSourceNames(state).has(translatedSourceName)) {
+ _volume = DUCKED_ORIGINAL_VOLUME;
+ ducked = true;
+ }
+ }
+
+ // When the feature is enabled, a track may have been ducked to a non-default volume. Once it is no longer
+ // ducked and has no explicit per-participant volume, restore full volume — otherwise the audio element keeps
+ // the previously-applied ducked level, since AudioTrack only writes numeric volumes (undefined is ignored).
+ if (!ducked && audioTranslationEnabled && _volume === undefined) {
+ _volume = DEFAULT_ORIGINAL_VOLUME;
+ }
return {
_muted: state['features/base/config'].startSilent,
- _volume: participantsVolume[ownProps.participantId]
+ _volume
};
}
diff --git a/react/features/base/participants/types.ts b/react/features/base/participants/types.ts
index 5ea2d9136f..72ecde9db6 100644
--- a/react/features/base/participants/types.ts
+++ b/react/features/base/participants/types.ts
@@ -69,6 +69,7 @@ export interface IParticipantFeatures {
'flip'?: boolean | string;
'inbound-call'?: boolean | string;
'list-visitors'?: boolean | string;
+ 'live-translation'?: boolean | string;
'livestreaming'?: boolean | string;
'lobby'?: boolean | string;
'moderation'?: boolean | string;
diff --git a/react/features/base/tracks/actions.any.ts b/react/features/base/tracks/actions.any.ts
index d03572c225..89a94bb62b 100644
--- a/react/features/base/tracks/actions.any.ts
+++ b/react/features/base/tracks/actions.any.ts
@@ -377,9 +377,16 @@ function replaceStoredTracks(oldTrack: any, newTrack: any) {
*/
export function trackAdded(track: any) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
- track.on(
- JitsiTrackEvents.TRACK_MUTE_CHANGED,
- () => dispatch(trackMutedChanged(track)));
+ // Translated audio tracks (source name <regularSourceName>.<language>) have no mute lifecycle, since
+ // presence/source-info is only signaled for the original source. Skip the inert mute listener for them.
+ const sourceName = track.getSourceName?.();
+ const isTranslatedTrack = typeof sourceName === 'string' && sourceName.includes('.');
+
+ if (!isTranslatedTrack) {
+ track.on(
+ JitsiTrackEvents.TRACK_MUTE_CHANGED,
+ () => dispatch(trackMutedChanged(track)));
+ }
track.on(
JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED,
(type: VideoType) => dispatch(trackVideoTypeChanged(track, type)));
diff --git a/react/features/settings/actions.web.ts b/react/features/settings/actions.web.ts
index 30708d2c72..cb3af7a8da 100644
--- a/react/features/settings/actions.web.ts
+++ b/react/features/settings/actions.web.ts
@@ -209,6 +209,14 @@ export function submitModeratorTab(newState: any) {
groupChatRestricted: newState.chatWithPermissionsEnabled
});
}
+
+ if (newState.audioTranslationEnabled !== currentState.audioTranslationEnabled) {
+ const { conference } = getState()['features/base/conference'];
+
+ conference?.getMetadataHandler().setMetadata('audioTranslation', {
+ enabled: newState.audioTranslationEnabled
+ });
+ }
};
}
diff --git a/react/features/settings/components/web/ModeratorTab.tsx b/react/features/settings/components/web/ModeratorTab.tsx
index 8a10edb4c2..a7152d1f3f 100644
--- a/react/features/settings/components/web/ModeratorTab.tsx
+++ b/react/features/settings/components/web/ModeratorTab.tsx
@@ -17,6 +17,11 @@ export interface IProps extends AbstractDialogTabProps, WithTranslation {
*/
audioModerationEnabled: boolean;
+ /**
+ * Whether audio translation is enabled for the room.
+ */
+ audioTranslationEnabled: boolean;
+
/**
* Whether the user has selected the chat with permissions feature to be enabled.
*/
@@ -57,6 +62,11 @@ export interface IProps extends AbstractDialogTabProps, WithTranslation {
*/
hideChatWithPermissions: boolean;
+ /**
+ * Whether the audio-translation room toggle should be shown (i.e. the feature is deployed).
+ */
+ showAudioTranslation: boolean;
+
/**
* Whether or not the user has selected the Start Audio Muted feature to be
* enabled.
@@ -122,6 +132,18 @@ class ModeratorTab extends AbstractDialogTab<IProps, any> {
this._onFollowMeEnabledChanged = this._onFollowMeEnabledChanged.bind(this);
this._onFollowMeRecorderEnabledChanged = this._onFollowMeRecorderEnabledChanged.bind(this);
this._onChatWithPermissionsChanged = this._onChatWithPermissionsChanged.bind(this);
+ this._onAudioTranslationEnabledChanged = this._onAudioTranslationEnabledChanged.bind(this);
+ }
+
+ /**
+ * Callback invoked to enable or disable audio translation for the whole room.
+ *
+ * @param {Object} e - The key event to handle.
+ *
+ * @returns {void}
+ */
+ _onAudioTranslationEnabledChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
+ super._onChange({ audioTranslationEnabled: checked });
}
/**
@@ -209,6 +231,7 @@ class ModeratorTab extends AbstractDialogTab<IProps, any> {
override render() {
const {
audioModerationEnabled,
+ audioTranslationEnabled,
chatWithPermissionsEnabled,
disableReactionsModeration,
followMeActive,
@@ -216,6 +239,7 @@ class ModeratorTab extends AbstractDialogTab<IProps, any> {
followMeRecorderActive,
followMeRecorderEnabled,
hideChatWithPermissions,
+ showAudioTranslation,
startAudioMuted,
startVideoMuted,
startReactionsMuted,
@@ -273,6 +297,13 @@ class ModeratorTab extends AbstractDialogTab<IProps, any> {
label = { t('settings.chatWithPermissions') }
name = 'chat-with-permissions'
onChange = { this._onChatWithPermissionsChanged } /> }
+ { showAudioTranslation
+ && <Checkbox
+ checked = { audioTranslationEnabled }
+ className = { classes.checkbox }
+ label = { t('settings.audioTranslation') }
+ name = 'audio-translation'
+ onChange = { this._onAudioTranslationEnabledChanged } /> }
</div>
);
}
diff --git a/react/features/settings/components/web/SettingsDialog.tsx b/react/features/settings/components/web/SettingsDialog.tsx
index c672389227..6eb17b6abf 100644
--- a/react/features/settings/components/web/SettingsDialog.tsx
+++ b/react/features/settings/components/web/SettingsDialog.tsx
@@ -254,6 +254,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
return {
...newProps,
+ audioTranslationEnabled: tabState?.audioTranslationEnabled,
chatWithPermissionsEnabled: tabState?.chatWithPermissionsEnabled,
followMeEnabled: tabState?.followMeEnabled,
followMeRecorderEnabled: tabState?.followMeRecorderEnabled,
diff --git a/react/features/settings/functions.any.ts b/react/features/settings/functions.any.ts
index d6c00f0208..c08e909aaa 100644
--- a/react/features/settings/functions.any.ts
+++ b/react/features/settings/functions.any.ts
@@ -162,7 +162,11 @@ export function getModeratorTabProps(stateful: IStateful) {
} = state['features/base/conference'];
const { followMeEnabled, followMeRecorderEnabled } = state['features/follow-me'];
const { groupChatWithPermissions } = state['features/chat'];
- const { showChatPermissionsModeratorSetting, disableReactionsModeration } = state['features/base/config'];
+ const {
+ audioTranslation,
+ showChatPermissionsModeratorSetting,
+ disableReactionsModeration
+ } = state['features/base/config'];
const followMeActive = isFollowMeActive(state);
const followMeRecorderActive = isFollowMeRecorderActive(state);
const showModeratorSettings = shouldShowModeratorSettings(state);
@@ -174,6 +178,8 @@ export function getModeratorTabProps(stateful: IStateful) {
// The settings sections to display.
return {
audioModerationEnabled: isAudioModerationEnabled,
+ audioTranslationEnabled: Boolean(conference) && conferenceMetadata?.audioTranslation?.enabled !== false,
+ showAudioTranslation: Boolean(audioTranslation?.enabled),
videoModerationEnabled: isVideoModerationEnabled,
chatWithPermissionsEnabled: Boolean(groupChatWithPermissions),
showModeratorSettings: Boolean(conference && showModeratorSettings),
diff --git a/react/features/toolbox/constants.ts b/react/features/toolbox/constants.ts
index 7c4d50a948..0398e1d607 100644
--- a/react/features/toolbox/constants.ts
+++ b/react/features/toolbox/constants.ts
@@ -146,6 +146,7 @@ export const SPINNER_COLOR = '#929292';
* @type Array<string>
*/
export const TOOLBAR_BUTTONS: ToolbarButton[] = [
+ 'audiotranslation',
'camera',
'chat',
'closedcaptions',
diff --git a/react/features/toolbox/hooks.web.ts b/react/features/toolbox/hooks.web.ts
index b780dbcf28..6988bfde2a 100644
--- a/react/features/toolbox/hooks.web.ts
+++ b/react/features/toolbox/hooks.web.ts
@@ -4,6 +4,7 @@ import { batch, useDispatch, useSelector } from 'react-redux';
import { ACTION_SHORTCUT_TRIGGERED, createShortcutEvent } from '../analytics/AnalyticsEvents';
import { sendAnalytics } from '../analytics/functions';
import { IReduxState } from '../app/types';
+import { useAudioTranslationButton } from '../audio-translation/hooks.web';
import { toggleDialog } from '../base/dialog/actions';
import { isIosMobileBrowser, isIpadMobileBrowser } from '../base/environment/utils';
import { HELP_BUTTON_ENABLED } from '../base/flags/constants';
@@ -291,6 +292,7 @@ export function useToolboxButtons(
const tileview = useTileViewButton();
const chat = useChatButton();
const cc = useClosedCaptionButton();
+ const audioTranslation = useAudioTranslationButton();
const polls = usePollsButton();
const filesharing = useFileSharingButton();
const recording = useRecordingButton();
@@ -326,6 +328,7 @@ export function useToolboxButtons(
fullscreen: _fullscreen,
security,
closedcaptions: cc,
+ audiotranslation: audioTranslation,
polls,
filesharing,
recording,
diff --git a/react/features/toolbox/types.ts b/react/features/toolbox/types.ts
index b125cebc32..d23fe2ce51 100644
--- a/react/features/toolbox/types.ts
+++ b/react/features/toolbox/types.ts
@@ -16,7 +16,8 @@ export interface IToolboxNativeButton {
text?: string;
}
-export type ToolbarButton = 'camera' |
+export type ToolbarButton = 'audiotranslation' |
+ 'camera' |
'chat' |
'closedcaptions' |
'custom-panel' |
diff --git a/react/features/video-menu/components/web/ParticipantContextMenu.tsx b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
index 521b9fe599..b1d7e22ab5 100644
--- a/react/features/video-menu/components/web/ParticipantContextMenu.tsx
+++ b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
@@ -4,6 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
import { IReduxState, IStore } from '../../../app/types';
+import { isAudioTranslationAvailable } from '../../../audio-translation/functions';
import { MEDIA_TYPE as AVM_MEDIA_TYPE } from '../../../av-moderation/constants';
import { isSupported as isAvModerationSupported, isForceMuted } from '../../../av-moderation/functions';
import Avatar from '../../../base/avatar/components/Avatar';
@@ -44,6 +45,7 @@ import PrivateMessageMenuButton from './PrivateMessageMenuButton';
import RemoteControlButton, { REMOTE_CONTROL_MENU_STATES } from './RemoteControlButton';
import SendToRoomButton from './SendToRoomButton';
import TogglePinToStageButton from './TogglePinToStageButton';
+import TranslateParticipantButton from './TranslateParticipantButton';
import VerifyParticipantButton from './VerifyParticipantButton';
import VolumeSlider from './VolumeSlider';
@@ -144,6 +146,7 @@ const ParticipantContextMenu = ({
const _overflowDrawer: boolean = useSelector(showOverflowDrawer);
const { remoteVideoMenu = {}, disableRemoteMute, startSilent, customParticipantMenuButtons }
= useSelector((state: IReduxState) => state['features/base/config']);
+ const _audioTranslationAvailable = useSelector(isAudioTranslationAvailable);
const visitorsSupported = useSelector((state: IReduxState) => state['features/visitors'].supported);
const { disableDemote, disableKick, disableGrantModerator } = remoteVideoMenu;
const { participantsVolume } = useSelector((state: IReduxState) => state['features/filmstrip']);
@@ -321,6 +324,10 @@ const ParticipantContextMenu = ({
);
}
+ if (_audioTranslationAvailable && !participant?.local) {
+ buttons2.push(<TranslateParticipantButton { ...getButtonProps(BUTTONS.TRANSLATE_AUDIO) } />);
+ }
+
const breakoutRoomsButtons: any = [];
if (!thumbnailMenu && _isModerator) {
diff --git a/react/features/video-menu/components/web/TranslateParticipantButton.tsx b/react/features/video-menu/components/web/TranslateParticipantButton.tsx
new file mode 100644
index 0000000000..2a0d19c79d
--- /dev/null
+++ b/react/features/video-menu/components/web/TranslateParticipantButton.tsx
@@ -0,0 +1,40 @@
+import React, { useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
+import { useDispatch } from 'react-redux';
+
+import AudioTranslationDialog from '../../../audio-translation/components/web/AudioTranslationDialog';
+import { openDialog } from '../../../base/dialog/actions';
+import { IconTranslate } from '../../../base/icons/svg';
+import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
+import { NOTIFY_CLICK_MODE } from '../../../toolbox/types';
+import { IButtonProps } from '../../types';
+
+/**
+ * A participant/thumbnail menu item that opens the AI audio-translation language
+ * selector scoped to a single participant.
+ *
+ * @param {IButtonProps} props - The component's props.
+ * @returns {JSX.Element}
+ */
+const TranslateParticipantButton = ({ notifyClick, notifyMode, participantID }: IButtonProps): JSX.Element => {
+ const dispatch = useDispatch();
+ const { t } = useTranslation();
+
+ const _onClick = useCallback(() => {
+ notifyClick?.();
+ if (notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY) {
+ return;
+ }
+ dispatch(openDialog('AudioTranslationDialog', AudioTranslationDialog, { participantId: participantID }));
+ }, [ dispatch, notifyClick, notifyMode, participantID ]);
+
+ return (
+ <ContextMenuItem
+ accessibilityLabel = { t('toolbar.audioTranslation') }
+ icon = { IconTranslate }
+ onClick = { _onClick }
+ text = { t('toolbar.audioTranslation') } />
+ );
+};
+
+export default TranslateParticipantButton;
diff --git a/react/features/video-menu/constants.ts b/react/features/video-menu/constants.ts
index da9ec197a4..cab9b204e5 100644
--- a/react/features/video-menu/constants.ts
+++ b/react/features/video-menu/constants.ts
@@ -37,5 +37,6 @@ export const PARTICIPANT_MENU_BUTTONS = {
PRIVATE_MESSAGE: 'privateMessage',
REMOTE_CONTROL: 'remote-control',
SEND_PARTICIPANT_TO_ROOM: 'send-participant-to-room',
+ TRANSLATE_AUDIO: 'translate-audio',
VERIFY: 'verify'
};