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

* configurable transcription language

* merge conflict

* set default config value

* fix lint
pull/9686/head jitsi-meet_6165
Andrei Gavrilescu 3 years ago committed by GitHub
parent 6f44368647
commit e45cab9a80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      config.js
  2. 2
      react/features/base/conference/functions.js
  3. 30
      react/features/transcribing/functions.js
  4. 51
      react/features/transcribing/jitsiToBCP47LocaleMap.json

@ -230,6 +230,17 @@ var config = {
// subtitles and buttons can be configured) // subtitles and buttons can be configured)
// transcribingEnabled: false, // 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 // Enables automatic turning on captions when recording is started
// autoCaptionOnRecord: false, // autoCaptionOnRecord: false,

@ -3,6 +3,7 @@
import _ from 'lodash'; import _ from 'lodash';
import { getName } from '../../app/functions'; import { getName } from '../../app/functions';
import { determineTranscriptionLanguage } from '../../transcribing/functions';
import { JitsiTrackErrors } from '../lib-jitsi-meet'; import { JitsiTrackErrors } from '../lib-jitsi-meet';
import { import {
getLocalParticipant, getLocalParticipant,
@ -231,6 +232,7 @@ export function getConferenceOptions(stateful: Function | Object) {
} }
options.applicationName = getName(); options.applicationName = getName();
options.transcriptionLanguage = determineTranscriptionLanguage(options);
// Disable analytics, if requessted. // Disable analytics, if requessted.
if (options.disableThirdPartyRequests) { if (options.disableThirdPartyRequests) {

@ -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;
}

@ -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)"
}
Loading…
Cancel
Save