Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
eab3df7
Update pushSpeechTranscript.js
hiroshisuga May 28, 2023
ca55fc2
Update startDictation.js
hiroshisuga May 28, 2023
c29c304
Update stopDictation.js
hiroshisuga May 28, 2023
9965c43
Update createCaptions.js
hiroshisuga May 28, 2023
03d06f7
Update updateCaptionsOwner.js
hiroshisuga May 28, 2023
cc82223
Update component.jsx
hiroshisuga May 28, 2023
9f4e84f
Update container.jsx
hiroshisuga May 28, 2023
d6fd312
Update component.jsx
hiroshisuga May 28, 2023
4711513
Update container.jsx
hiroshisuga May 28, 2023
f421853
Update component.jsx
hiroshisuga May 28, 2023
9dc5f71
Update container.jsx
hiroshisuga May 28, 2023
c0bbd9b
Update service.js
hiroshisuga May 28, 2023
b46fd12
Update component.jsx
hiroshisuga May 28, 2023
2b57a61
Update service.js
hiroshisuga May 28, 2023
a9f6805
Update styles.js
hiroshisuga May 28, 2023
715b145
Update container.jsx
hiroshisuga May 28, 2023
b5084f0
Update component.jsx
hiroshisuga May 28, 2023
e88a063
Update component.jsx
hiroshisuga May 28, 2023
29077de
Update component.jsx
hiroshisuga May 28, 2023
2af5ba2
Update container.jsx
hiroshisuga May 28, 2023
1eb7f78
Update settings.yml
hiroshisuga May 28, 2023
7fbbffe
Update en.json
hiroshisuga May 28, 2023
a61021d
Update methods.js
hiroshisuga May 28, 2023
06b15ac
Create enableAutoTranslation.js
hiroshisuga May 28, 2023
073f0fe
Create disableAutoTranslation.js
hiroshisuga May 28, 2023
485199f
Update disableAutoTranslation.js
hiroshisuga May 28, 2023
f5133f1
Update enableAutoTranslation.js
hiroshisuga May 28, 2023
6ee3414
Create setAutoTranslation.js
hiroshisuga May 28, 2023
1d692e9
Update disableAutoTranslation.js
hiroshisuga May 28, 2023
0c1dad1
Update enableAutoTranslation.js
hiroshisuga May 28, 2023
7e75ff1
Update component.jsx
hiroshisuga May 28, 2023
75cfb51
Update component.jsx
hiroshisuga May 28, 2023
bd69628
Update service.js
hiroshisuga May 28, 2023
4502f61
Update pushSpeechTranscript.js
hiroshisuga May 28, 2023
97b3444
Update component.jsx
hiroshisuga May 28, 2023
80a8a61
Update component.jsx
hiroshisuga May 28, 2023
5c60ea7
Update component.jsx
hiroshisuga May 28, 2023
0790250
Update package.json
hiroshisuga May 28, 2023
c7d62a4
Update service.js
hiroshisuga May 28, 2023
41e77f6
Update component.jsx
hiroshisuga May 28, 2023
4cf3c8a
Update service.js
hiroshisuga May 28, 2023
ee77ad6
Update component.jsx
hiroshisuga May 28, 2023
1398989
bug for optional array
hiroshisuga May 29, 2023
8a6f6b2
remove enableAutoTranslation
hiroshisuga May 29, 2023
7695daa
Update disableAutoTranslation.js
hiroshisuga May 29, 2023
30be0ec
Update enableAutoTranslation.js
hiroshisuga May 29, 2023
2c78725
Update setAutoTranslation.js
hiroshisuga May 29, 2023
ed0b492
add react-select in package-lock.json
hiroshisuga May 29, 2023
f619ccd
some bug fixed
hiroshisuga May 30, 2023
45a2cce
modify comment but not sure
hiroshisuga May 30, 2023
854c334
Delete startDictation.js
hiroshisuga May 31, 2023
73ebd05
Delete stopDictation.js
hiroshisuga May 31, 2023
05f6961
Delete enableAutoTranslation.js
hiroshisuga May 31, 2023
aad61b0
Delete disableAutoTranslation.js
hiroshisuga May 31, 2023
1403bd9
Create addTranslation.js
hiroshisuga May 31, 2023
ca72676
Create removeTranslation.js
hiroshisuga May 31, 2023
680fc0b
Create provideSpeech.js
hiroshisuga May 31, 2023
77f8c0c
Create retractSpeech.js
hiroshisuga May 31, 2023
7074235
add Logger before translateText
hiroshisuga May 31, 2023
abe09cd
Update methods.js
hiroshisuga May 31, 2023
da35728
Add update "translating" when removing a user
hiroshisuga May 31, 2023
38bb977
set "dictating" false when all dictators leave
hiroshisuga May 31, 2023
facee15
Update component.jsx
hiroshisuga May 31, 2023
5d1e0e8
Move many functions to API
hiroshisuga May 31, 2023
42d00f5
get"My"LocalesAutoTranslated
hiroshisuga May 31, 2023
56fe7a0
Remove isUserCaptionOwner condition
hiroshisuga May 31, 2023
090dd57
Remove Pads.hasAccess condition
hiroshisuga May 31, 2023
a43957a
check if locale is empty
hiroshisuga Jun 2, 2023
6a82f34
fix bug: add Caption.upsert that was missing
hiroshisuga Jun 2, 2023
2c424a8
日本語の翻訳を追加
hiroshisuga Jun 3, 2023
6185722
Comment: pushSpeechTranscript.js
hiroshisuga Jun 15, 2023
67e8df0
fix: don't translate interim
hiroshisuga Jun 15, 2023
b5af671
avatar
hiroshisuga Jun 15, 2023
8aa328e
avatar
hiroshisuga Jun 15, 2023
dc02150
avatar
hiroshisuga Jun 15, 2023
dbc9f83
avatar
hiroshisuga Jun 15, 2023
2db175f
avatar
hiroshisuga Jun 16, 2023
aba10a7
avatar
hiroshisuga Jun 16, 2023
eb162d9
avatar
hiroshisuga Jun 16, 2023
3283c70
avarat
hiroshisuga Jun 16, 2023
8fc3393
avatar
hiroshisuga Jun 16, 2023
5243c6c
avatar
hiroshisuga Jun 16, 2023
180d8f7
avatar
hiroshisuga Jun 18, 2023
a947817
avatar
hiroshisuga Jun 18, 2023
c8e9134
avatar
hiroshisuga Jun 18, 2023
ab14825
avatar
hiroshisuga Jun 18, 2023
798e382
avatar
hiroshisuga Jun 18, 2023
875f2ef
Google Translation locale without -XX
hiroshisuga Jun 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CaptionApp2x(implicit val context: ActorContext) extends RightsManagementT
}

if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId)
&& isUserCaptionOwner(liveMeeting, msg.header.userId, msg.body.name)) {
/*&& isUserCaptionOwner(liveMeeting, msg.header.userId, msg.body.name)*/) {
val meetingId = liveMeeting.props.meetingProp.intId
val reason = "No permission to edit caption history in meeting."
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ trait PadUpdatePubMsgHdlr {
bus.outGW.send(msgEvent)
}

if (Pads.hasAccess(liveMeeting, msg.body.externalId, msg.header.userId)) {
//if (Pads.hasAccess(liveMeeting, msg.body.externalId, msg.header.userId)) {
Pads.getGroup(liveMeeting.pads, msg.body.externalId) match {
case Some(group) => broadcastEvent(group.groupId, msg.body.externalId, msg.body.text)
case _ =>
}
}
//}
}
}
12 changes: 8 additions & 4 deletions bigbluebutton-html5/imports/api/captions/server/methods.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Meteor } from 'meteor/meteor';
import updateCaptionsOwner from '/imports/api/captions/server/methods/updateCaptionsOwner';
import startDictation from '/imports/api/captions/server/methods/startDictation';
import stopDictation from '/imports/api/captions/server/methods/stopDictation';
import provideSpeech from '/imports/api/captions/server/methods/provideSpeech';
import retractSpeech from '/imports/api/captions/server/methods/retractSpeech';
import pushSpeechTranscript from '/imports/api/captions/server/methods/pushSpeechTranscript';
import addTranslation from '/imports/api/captions/server/methods/addTranslation';
import removeTranslation from '/imports/api/captions/server/methods/removeTranslation';

Meteor.methods({
updateCaptionsOwner,
startDictation,
stopDictation,
provideSpeech,
retractSpeech,
pushSpeechTranscript,
addTranslation,
removeTranslation,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { check } from 'meteor/check';
import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import setAutoTranslation from '/imports/api/captions/server/modifiers/setAutoTranslation';

export default function addTranslation(locale) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);

check(locale, String);
check(meetingId, String);
check(requesterUserId, String);

//const caption = Captions.findOne({ meetingId, locale }, { fields: { translating:1 } });
setAutoTranslation(meetingId, locale, requesterUserId, true);
} catch (err) {
Logger.error(`Exception while invoking method enableAutoTranslation ${err.stack}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import setDictation from '/imports/api/captions/server/modifiers/setDictation';

export default function stopDictation(locale) {
export default function provideSpeech(locale) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);

Expand All @@ -14,12 +14,11 @@ export default function stopDictation(locale) {

const captions = Captions.findOne({
meetingId,
ownerId: requesterUserId,
locale,
});

if (captions) setDictation(meetingId, locale, false);
if (captions) setDictation(meetingId, locale, requesterUserId, true);
} catch (err) {
Logger.error(`Exception while invoking method stopDictation ${err.stack}`);
Logger.error(`Exception while invoking method provideSpeech ${err.stack}`);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,68 @@
import { check } from 'meteor/check';
import Captions from '/imports/api/captions';
import Users from '/imports/api/users';
import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import setTranscript from '/imports/api/captions/server/modifiers/setTranscript';
import updatePad from '/imports/api/pads/server/methods/updatePad';
import axios from 'axios';

export default function pushSpeechTranscript(locale, transcript, type) {
const CAPTIONS_CONFIG = Meteor.settings.public.captions;

function sendTranscript(meetingId, requesterUserId, type, dst, text) {
const user = Users.findOne({meetingId, userId: requesterUserId}, { fields: {name: 1}});
//console.log("sendTranscript", text);
//const textWithName = `${user.name}: ${text}`;
if (type === 'final') {
//const textLf = `\n${textWithName}`;
const textLf = `\n${text}`;
updatePad(meetingId, requesterUserId, dst, textLf); // Pad and recording
}
setTranscript(meetingId, dst, text, requesterUserId); // Live
}

function translateText(meetingId, requesterUserId, textOri, type, src, dst) {
if ( !CAPTIONS_CONFIG.enableAutomaticTranslation || textOri === "" || !dst || dst === "" || dst === src || dst.replace(/-..$/,'') === src || dst === src.replace(/-..$/,'') ) {
sendTranscript(meetingId, requesterUserId, type, dst, textOri);
} else {
let url = '';
if (CAPTIONS_CONFIG.googleTranslateUrl) {
url = CAPTIONS_CONFIG.googleTranslateUrl + '/exec?' +
'text=' + encodeURIComponent(textOri) + '&source=' + src + '&target=' + dst.replace(/-..$/,'');
} else if (CAPTIONS_CONFIG.deeplTranslateUrl) {
url = CAPTIONS_CONFIG.deeplTranslateUrl +
'&text=' + encodeURIComponent(textOri) + '&source_lang=' + src.replace(/-..$/,'').toUpperCase() +
'&target_lang=' + dst.toUpperCase();
} else {
Logger.error('Could not get a translation service.');
return;
}

axios({
method: 'get',
url,
responseType: 'json',
}).then((response) => {
if (CAPTIONS_CONFIG.googleTranslateUrl) {
const { code, text } = response.data;
if (code === 200) {
sendTranscript(meetingId, requesterUserId, type, dst, text);
} else {
Logger.error(`Failed to get Google translation for ${textOri}`);
}
} else if (CAPTIONS_CONFIG.deeplTranslateUrl) {
const { translations } = response.data;
if (translations.length > 0 && translations[0].text) {
sendTranscript(meetingId, requesterUserId, type, dst, translations[0].text);
} else {
Logger.error(`Failed to get DeepL translation for ${textOri}`);
}
}
}).catch((error) => Logger.error(`Could not get translation for ${textOri.trim()} on the locale ${dst}: ${error}`));
}
}

export default function pushSpeechTranscript(locale, transcript, type, locales) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);

Expand All @@ -14,22 +71,23 @@ export default function pushSpeechTranscript(locale, transcript, type) {
check(locale, String);
check(transcript, String);
check(type, String);
check(locales, Array);

const captions = Captions.findOne({
meetingId,
ownerId: requesterUserId,
locale,
dictating: true,
});
locales.forEach(function(dstLocale, index) {
const caption = Captions.findOne({
meetingId,
locale: dstLocale,
});

if (captions) {
if (type === 'final') {
const text = `\n${transcript}`;
updatePad(meetingId, requesterUserId, locale, text);
if (!caption) {
Logger.error(`Could not find the caption's pad for meetingId=${meetingId} locale=${locale}`);
} else {
if (type === 'final' || ( type === 'interim' && locale === dstLocale ) ) {
Logger.debug(`Transcription being translated from ${locale} into ${dstLocale}`);
translateText(meetingId, requesterUserId, transcript, type, locale, dstLocale);
}
}

setTranscript(meetingId, locale, transcript);
}
});
} catch (err) {
Logger.error(`Exception while invoking method pushSpeechTranscript ${err.stack}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { check } from 'meteor/check';
import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import setAutoTranslation from '/imports/api/captions/server/modifiers/setAutoTranslation';

export default function removeTranslation(locale) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);

check(locale, String);
check(meetingId, String);
check(requesterUserId, String);

//const caption = Captions.findOne({ meetingId, locale }, { fields: { translating:1 } });
setAutoTranslation(meetingId, locale, requesterUserId, false);
} catch (err) {
Logger.error(`Exception while invoking method disbleAutoTranslation ${err.stack}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import setDictation from '/imports/api/captions/server/modifiers/setDictation';

export default function startDictation(locale) {
export default function retractSpeech(locale) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);

Expand All @@ -14,12 +14,11 @@ export default function startDictation(locale) {

const captions = Captions.findOne({
meetingId,
ownerId: requesterUserId,
locale,
});

if (captions) setDictation(meetingId, locale, true);
if (captions) setDictation(meetingId, locale, requesterUserId, false);
} catch (err) {
Logger.error(`Exception while invoking method startDictation ${err.stack}`);
Logger.error(`Exception while invoking method retractSpeech ${err.stack}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export default function createCaptions(meetingId, locale, name) {
ownerId: '',
dictating: false,
transcript: '',
translating: false,
translationDoner: {},
speechDoner: {},
};

const numberAffected = Captions.upsert(selector, modifier);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//Do we need this? It just sets "translating" -> seems yes
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';

export default function setAutoTranslation(meetingId, locale, userId, selecting) {
check(meetingId, String);
check(locale, String);
check(userId, String);
check(selecting, Boolean);

const selector = {
meetingId,
locale,
};

let modifier;
if (selecting) {
modifier = {
$set: {
['translationDoner.'+userId]: true,
translating: true,
}
};
} else {
modifier = {
$set: {
['translationDoner.'+userId]: false,
}
};
}

try {
const numberAffected = Captions.update(selector, modifier);
Logger.info(`Adding/Removing (${selecting}) translationDoner ${locale} from ${userId} meeting=${meetingId}`);
if (numberAffected) {
Logger.verbose('Captions: updated pad autoTranslation', { locale });
}
} catch (err) {
Logger.error(`Updating captions pad autoTranslation: ${err}`);
}

if (!selecting) {
const newcap = Captions.findOne({ meetingId, locale }, { fields: { translationDoner: 1 } });
const td = newcap.translationDoner;
if (!Object.values(td).includes(true)) {
const modifier2 = {
$set: {
translating: false,
},
};
try {
const numberAffected = Captions.upsert({ meetingId, locale }, modifier2);
if (numberAffected) {
Logger.info(`Updating translating to false; ${locale}, meeting=${meetingId} in Captions`);
}
} catch (err) {
Logger.error(`Updating translating: ${err} in Captions`);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,56 @@ import { check } from 'meteor/check';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';

export default function setDictation(meetingId, locale, dictating) {
export default function setDictation(meetingId, locale, userId, providing) {
try {
check(meetingId, String);
check(locale, String);
check(dictating, Boolean);
check(userId, String);
check(providing, Boolean);

const selector = {
meetingId,
locale,
};

const modifier = {
$set: {
dictating,
transcript: '',
},
};
let modifier;
if (providing) {
modifier = {
$set: {
['speechDoner.'+userId]: true,
dictating: true,
},
};
} else {
modifier = {
$set: {
['speechDoner.'+userId]: false,
},
};
}

const numberAffected = Captions.upsert(selector, modifier);

if (numberAffected) {
Logger.info(`Set captions=${locale} dictating=${dictating} meeting=${meetingId}`);
Logger.info(`Set captions=${locale} provide?=${providing} meeting=${meetingId}, userId=${userId}`);
} else {
Logger.info(`Upserted captions=${locale} dictating=${dictating} meeting=${meetingId}`);
Logger.info(`Upserted captions=${locale} provide?=${providing} meeting=${meetingId}, userId=${userId}`);
}

if (!providing) {
const newcap = Captions.findOne({ meetingId, locale }, { fields: { speechDoner: 1 } });
const sd = newcap.speechDoner;
if (!Object.values(sd).includes(true)) {
const modifier2 = {
$set: {
dictating: false,
},
};
const numberAffected = Captions.upsert({ meetingId, locale }, modifier2);
if (numberAffected) {
Logger.info(`Updating dicatating to false; ${locale}, meeting=${meetingId} in Captions`);
}
}
}
} catch (err) {
Logger.error(`Setting captions dictation to the collection: ${err}`);
Expand Down
Loading