bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/methods/setSpeechLocale.js
Pedro Beschorner Marin 51eeb092b3 refactor(captions): configurable languages
Move the language collection to the HTML settings file. This data defines
the available languages available for the speech API.

These language tags are used to filter SpeechSynthesis' API `getVoices`
result. Tags must use BCP 47 format.

https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisVoice/lang
2022-07-20 17:20:52 +00:00

23 lines
769 B
JavaScript

import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import updateSpeechLocale from '../modifiers/updateSpeechLocale';
import { extractCredentials } from '/imports/api/common/server/helpers';
const LANGUAGES = Meteor.settings.public.app.audioCaptions.language.available;
export default function setSpeechLocale(locale) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(locale, String);
if (LANGUAGES.includes(locale) || locale === '') {
updateSpeechLocale(meetingId, requesterUserId, locale);
}
} catch (err) {
Logger.error(`Exception while invoking method setSpeechLocale ${err.stack}`);
}
}