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(transcribing): configurable transcription language (#9684)

Andrei Gavrilescue45cab9a80b7
diff --git a/config.js b/config.js
index 7993959f3c..1264a27ce0 100644
--- a/config.js
+++ b/config.js
@@ -230,6 +230,17 @@ var config = {
// subtitles and buttons can be configured)
// transcribingEnabled: false,
+ // If true transcriber will use the application language.
+ // The application language is either explicitly set by participants in their settings or automatically
+ // detected based on the environment, e.g. if the app is opened in a chrome instance which is using french as its
+ // default language then transcriptions for that participant will be in french.
+ // Defaults to true.
+ // transcribeWithAppLanguage: true,
+
+ // Transcriber language. This settings will only work if "transcribeWithAppLanguage" is explicitly set to false.
+ // Available languages can be found in lang/language.json.
+ // preferredTranscribeLanguage: 'en',
+
// Enables automatic turning on captions when recording is started
// autoCaptionOnRecord: false,
diff --git a/react/features/base/conference/functions.js b/react/features/base/conference/functions.js
index 17017dfc6c..f4a000e848 100644
--- a/react/features/base/conference/functions.js
+++ b/react/features/base/conference/functions.js
@@ -3,6 +3,7 @@
import _ from 'lodash';
import { getName } from '../../app/functions';
+import { determineTranscriptionLanguage } from '../../transcribing/functions';
import { JitsiTrackErrors } from '../lib-jitsi-meet';
import {
getLocalParticipant,
@@ -231,6 +232,7 @@ export function getConferenceOptions(stateful: Function | Object) {
}
options.applicationName = getName();
+ options.transcriptionLanguage = determineTranscriptionLanguage(options);
// Disable analytics, if requessted.
if (options.disableThirdPartyRequests) {
diff --git a/react/features/transcribing/functions.js b/react/features/transcribing/functions.js
new file mode 100644
index 0000000000..13bacd5ce3
--- /dev/null
+++ b/react/features/transcribing/functions.js
@@ -0,0 +1,30 @@
+// @flow
+
+import i18next from 'i18next';
+
+import JITSI_TO_BCP47_MAP from './jitsiToBCP47LocaleMap.json';
+
+const DEFAULT_TRANSCRIBER_LANG = 'en-US';
+
+
+/**
+ * Determine which language to use for transcribing.
+ *
+ * @param {*} config - Application config.
+ * @returns {string}
+ */
+export function determineTranscriptionLanguage(config: Object) {
+
+ const { preferredTranscribeLanguage, transcribeWithAppLanguage = true } = config;
+
+ // Depending on the config either use the language that the app automatically detected or the hardcoded
+ // config value.
+ const jitsiLocale = transcribeWithAppLanguage ? i18next.language : preferredTranscribeLanguage;
+
+ // Jitsi uses custom language tags, but the transcriber expects BCP-47 compliant tags. We use a mapping file
+ // to convert them.
+ // Not all languages that the app might detect are supported by the transcriber in which case use the default.
+ const { [jitsiLocale]: bcp47Locale = DEFAULT_TRANSCRIBER_LANG } = JITSI_TO_BCP47_MAP;
+
+ return bcp47Locale;
+}
diff --git a/react/features/transcribing/jitsiToBCP47LocaleMap.json b/react/features/transcribing/jitsiToBCP47LocaleMap.json
new file mode 100644
index 0000000000..e769ef1014
--- /dev/null
+++ b/react/features/transcribing/jitsiToBCP47LocaleMap.json
@@ -0,0 +1,51 @@
+{
+ "en": "en-US",
+ "af": "af-ZA",
+ "ar": "ar-EG",
+ "bg": "bg-BG",
+ "ca": "ca-ES",
+ "cs": "cs-CZ",
+ "da": "da-DK",
+ "de": "de-DE",
+ "el": "el-GR",
+ "enGB": "en-GB",
+ "es": "es-ES",
+ "esUS": "es-US",
+ "et": "et-EE",
+ "eu": "eu-ES",
+ "fi": "fi-FI",
+ "fr": "fr-FR",
+ "frCA": "fr-CA",
+ "he": "iw-IL",
+ "hi": "hi-IN",
+ "mr": "mr-IN",
+ "hr": "hr-HR",
+ "hu": "hu-HU",
+ "hy": "hy-AM",
+ "id": "id-ID",
+ "it": "it-IT",
+ "ja": "ja-JP",
+ "ko": "ko-KR",
+ "lt": "lt-LT",
+ "ml": "ml-IN",
+ "lv": "lv-LV",
+ "nl": "nl-NL",
+ "fa": "fa-IR",
+ "pl": "pl-PL",
+ "pt": "pt-PT",
+ "ptBR": "pt-BR",
+ "ru": "ru-RU",
+ "ro": "ro-RO",
+ "sk": "sk-SK",
+ "sl": "sl-SL",
+ "sr": "sr-RS",
+ "sq": "sq-AL",
+ "sv": "sv-SE",
+ "te": "te-IN",
+ "th": "th-TH",
+ "tr": "tr-TR",
+ "uk": "uk-UA",
+ "vi": "vi-VN",
+ "zhCN": "zh (cmn-Hans-CN)",
+ "zhTW": "zh-TW (cmn-Hant-TW)"
+}
\ No newline at end of file