Browse Source

feat(transcribing): configurable transcription language (#9684)

* configurable transcription language

* merge conflict

* set default config value

* fix lint
master
Andrei Gavrilescu 4 years ago
parent
commit
e45cab9a80
No account linked to committer's email address

+ 11
- 0
config.js View File

230
     // subtitles and buttons can be configured)
230
     // subtitles and buttons can be configured)
231
     // transcribingEnabled: false,
231
     // transcribingEnabled: false,
232
 
232
 
233
+    // If true transcriber will use the application language.
234
+    // The application language is either explicitly set by participants in their settings or automatically
235
+    // detected based on the environment, e.g. if the app is opened in a chrome instance which is using french as its
236
+    // default language then transcriptions for that participant will be in french.
237
+    // Defaults to true.
238
+    // transcribeWithAppLanguage: true,
239
+
240
+    // Transcriber language. This settings will only work if "transcribeWithAppLanguage" is explicitly set to false.
241
+    // Available languages can be found in lang/language.json.
242
+    // preferredTranscribeLanguage: 'en',
243
+
233
     // Enables automatic turning on captions when recording is started
244
     // Enables automatic turning on captions when recording is started
234
     // autoCaptionOnRecord: false,
245
     // autoCaptionOnRecord: false,
235
 
246
 

+ 2
- 0
react/features/base/conference/functions.js View File

3
 import _ from 'lodash';
3
 import _ from 'lodash';
4
 
4
 
5
 import { getName } from '../../app/functions';
5
 import { getName } from '../../app/functions';
6
+import { determineTranscriptionLanguage } from '../../transcribing/functions';
6
 import { JitsiTrackErrors } from '../lib-jitsi-meet';
7
 import { JitsiTrackErrors } from '../lib-jitsi-meet';
7
 import {
8
 import {
8
     getLocalParticipant,
9
     getLocalParticipant,
231
     }
232
     }
232
 
233
 
233
     options.applicationName = getName();
234
     options.applicationName = getName();
235
+    options.transcriptionLanguage = determineTranscriptionLanguage(options);
234
 
236
 
235
     // Disable analytics, if requessted.
237
     // Disable analytics, if requessted.
236
     if (options.disableThirdPartyRequests) {
238
     if (options.disableThirdPartyRequests) {

+ 30
- 0
react/features/transcribing/functions.js View File

1
+// @flow
2
+
3
+import i18next from 'i18next';
4
+
5
+import JITSI_TO_BCP47_MAP from './jitsiToBCP47LocaleMap.json';
6
+
7
+const DEFAULT_TRANSCRIBER_LANG = 'en-US';
8
+
9
+
10
+/**
11
+ * Determine which language to use for transcribing.
12
+ *
13
+ * @param {*} config - Application config.
14
+ * @returns {string}
15
+ */
16
+export function determineTranscriptionLanguage(config: Object) {
17
+
18
+    const { preferredTranscribeLanguage, transcribeWithAppLanguage = true } = config;
19
+
20
+    // Depending on the config either use the language that the app automatically detected or the hardcoded
21
+    // config value.
22
+    const jitsiLocale = transcribeWithAppLanguage ? i18next.language : preferredTranscribeLanguage;
23
+
24
+    // Jitsi uses custom language tags, but the transcriber expects BCP-47 compliant tags. We use a mapping file
25
+    // to convert them.
26
+    // Not all languages that the app might detect are supported by the transcriber in which case use the default.
27
+    const { [jitsiLocale]: bcp47Locale = DEFAULT_TRANSCRIBER_LANG } = JITSI_TO_BCP47_MAP;
28
+
29
+    return bcp47Locale;
30
+}

+ 51
- 0
react/features/transcribing/jitsiToBCP47LocaleMap.json View File

1
+{
2
+    "en": "en-US",
3
+    "af": "af-ZA",
4
+    "ar": "ar-EG",
5
+    "bg": "bg-BG",
6
+    "ca": "ca-ES",
7
+    "cs": "cs-CZ",
8
+    "da": "da-DK",
9
+    "de": "de-DE",
10
+    "el": "el-GR",
11
+    "enGB": "en-GB",
12
+    "es": "es-ES",
13
+    "esUS": "es-US",
14
+    "et": "et-EE",
15
+    "eu": "eu-ES",
16
+    "fi": "fi-FI",
17
+    "fr": "fr-FR",
18
+    "frCA": "fr-CA",
19
+    "he": "iw-IL",
20
+    "hi": "hi-IN",
21
+    "mr": "mr-IN",
22
+    "hr": "hr-HR",
23
+    "hu": "hu-HU",
24
+    "hy": "hy-AM",
25
+    "id": "id-ID",
26
+    "it": "it-IT",
27
+    "ja": "ja-JP",
28
+    "ko": "ko-KR",
29
+    "lt": "lt-LT",
30
+    "ml": "ml-IN",
31
+    "lv": "lv-LV",
32
+    "nl": "nl-NL",
33
+    "fa": "fa-IR",
34
+    "pl": "pl-PL",
35
+    "pt": "pt-PT",
36
+    "ptBR": "pt-BR",
37
+    "ru": "ru-RU",
38
+    "ro": "ro-RO",
39
+    "sk": "sk-SK",
40
+    "sl": "sl-SL",
41
+    "sr": "sr-RS",
42
+    "sq": "sq-AL",
43
+    "sv": "sv-SE",
44
+    "te": "te-IN",
45
+    "th": "th-TH",
46
+    "tr": "tr-TR",
47
+    "uk": "uk-UA",
48
+    "vi": "vi-VN",
49
+    "zhCN": "zh (cmn-Hans-CN)",
50
+    "zhTW": "zh-TW (cmn-Hant-TW)"
51
+}

Loading…
Cancel
Save