bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/captions/component.jsx
Lucas 125d70699b
feat: Initial implementation of Gladia transcriptions to BBB 2.7 (#19091)
* Demo changes

* Revert "feat(captions): no longer writes in the pad"

This reverts commit a76de8c458.

* feat(transcriptoin): Add config options for the transcription backend

* feat(transcription): Add autodetect option to cc chevron

* feat(transcription): Move transcription options into settings modal

* feat(transcription): Set transcription options via userdata

* fix(transcription): Correct userdata for settings transcription params

* feat(transcriptions): options to auto enable caption button

* feat(transcriptions): Option to hide old CC pad funcionality

* fix(transcription): Fix PR comments

* fix(transcription): Refactor updateTranscript to prevent null user and make it more readable

* feat(transcription): bbb_transcription_provider can be set via userdata

* fix(transcription): Use base10 for parseInt

* fix(transcriptions): Fix CC language divider when using webspeech

* fix(transcriptions): Use a default pad in the settings instead of hardcoding 'en'

We still need to use a language pad such as 'en', but in the future we can better
separate these systems.

* fix(transcription): Add a special permission for automatic transcription updates to the pad and restore old per user updates permission

* feature(transcriptions): Include transcriptions submenu and locales

* chore: bump bbb-transcription-controller to v0.2.0

* fix(transcription): Add missing menu files

* fix(transcription): Fix transcription provider options in settings.yml

* fix: setting password for bbb-transcription-controller

* build: add gladia-proxy.log for transcription-controller

* fix(transcriptions): Remove transcript splitting and floor logic from akka apps

* fix(captions): Show long utterances as split captions, show multiple speaker captions

* chore: bump bbb-transcription-controller to 0.2.1

---------

Co-authored-by: Anton Georgiev <anto.georgiev@gmail.com>
2023-11-30 10:10:36 -05:00

137 lines
4.3 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
import Button from '/imports/ui/components/common/button/component';
import PadContainer from '/imports/ui/components/pads/container';
import Service from '/imports/ui/components/captions/service';
import Styled from './styles';
import { PANELS, ACTIONS } from '/imports/ui/components/layout/enums';
import browserInfo from '/imports/utils/browserInfo';
import Header from '/imports/ui/components/common/control-header/component';
const intlMessages = defineMessages({
title: {
id: 'app.captions.title',
description: 'Title for the pad header',
},
hide: {
id: 'app.captions.hide',
description: 'Label for hiding closed captions',
},
takeOwnership: {
id: 'app.captions.ownership',
description: 'Label for taking ownership of closed captions',
},
takeOwnershipTooltip: {
id: 'app.captions.ownershipTooltip',
description: 'Text for button for taking ownership of closed captions',
},
dictationStart: {
id: 'app.captions.dictationStart',
description: 'Label for starting speech recognition',
},
dictationStop: {
id: 'app.captions.dictationStop',
description: 'Label for stoping speech recognition',
},
dictationOnDesc: {
id: 'app.captions.dictationOnDesc',
description: 'Aria description for button that turns on speech recognition',
},
dictationOffDesc: {
id: 'app.captions.dictationOffDesc',
description: 'Aria description for button that turns off speech recognition',
},
});
const propTypes = {
locale: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
ownerId: PropTypes.string.isRequired,
intl: PropTypes.shape({
formatMessage: PropTypes.func.isRequired,
}).isRequired,
dictation: PropTypes.bool.isRequired,
dictating: PropTypes.bool.isRequired,
isRTL: PropTypes.bool.isRequired,
hasPermission: PropTypes.bool.isRequired,
layoutContextDispatch: PropTypes.func.isRequired,
isResizing: PropTypes.bool.isRequired,
};
const Captions = ({
locale,
intl,
ownerId,
name,
dictation,
dictating,
isRTL,
hasPermission,
layoutContextDispatch,
isResizing,
autoTranscription,
}) => {
const { isChrome } = browserInfo;
return (
<Styled.Captions isChrome={isChrome}>
<Header
leftButtonProps={{
onClick: () => {
layoutContextDispatch({
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
value: false,
});
layoutContextDispatch({
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
value: PANELS.NONE,
});
},
'aria-label': intl.formatMessage(intlMessages.hide),
label: autoTranscription ? intl.formatMessage(intlMessages.title) : name,
}}
customRightButton={Service.amICaptionsOwner(ownerId) ? (
<span>
<Button
onClick={dictating
? () => Service.stopDictation(locale)
: () => Service.startDictation(locale)}
label={dictating
? intl.formatMessage(intlMessages.dictationStop)
: intl.formatMessage(intlMessages.dictationStart)}
aria-describedby="dictationBtnDesc"
color={dictating ? 'danger' : 'primary'}
disabled={!dictation}
/>
<div id="dictationBtnDesc" hidden>
{dictating
? intl.formatMessage(intlMessages.dictationOffDesc)
: intl.formatMessage(intlMessages.dictationOnDesc)}
</div>
</span>
) : (
<Button
color="primary"
tooltipLabel={intl.formatMessage(intlMessages.takeOwnershipTooltip, { 0: name })}
onClick={() => Service.updateCaptionsOwner(locale, name)}
aria-label={intl.formatMessage(intlMessages.takeOwnership)}
label={intl.formatMessage(intlMessages.takeOwnership)}
/>
)}
/>
<PadContainer
externalId={locale}
hasPermission={hasPermission}
isResizing={isResizing}
isRTL={isRTL}
/>
</Styled.Captions>
);
};
Captions.propTypes = propTypes;
export default injectWbResizeEvent(injectIntl(Captions));