Просмотр исходного кода

feat(conference) add ability to change the transcription language

release-8443
Saúl Ibarra Corretgé 10 месяцев назад
Родитель
Сommit
db24997a89
1 измененных файлов: 23 добавлений и 3 удалений
  1. 23
    3
      JitsiConference.js

+ 23
- 3
JitsiConference.js Просмотреть файл

@@ -79,6 +79,11 @@ const logger = getLogger(__filename);
79 79
  */
80 80
 const JINGLE_SI_TIMEOUT = 5000;
81 81
 
82
+/**
83
+ * Default source language for transcribing the local participant.
84
+ */
85
+const DEFAULT_TRANSCRIPTION_LANGUAGE = 'en-US';
86
+
82 87
 /**
83 88
  * Checks if a given string is a valid video codec mime type.
84 89
  *
@@ -567,8 +572,10 @@ JitsiConference.prototype._init = function(options = {}) {
567 572
     // In case the language config is undefined or has the default value that the transcriber uses
568 573
     // (in our case Jigasi uses 'en-US'), don't set the participant property in order to avoid
569 574
     // needlessly polluting the presence stanza.
570
-    if (config && config.transcriptionLanguage && config.transcriptionLanguage !== 'en-US') {
571
-        this.setLocalParticipantProperty('transcription_language', config.transcriptionLanguage);
575
+    const transcriptionLanguage = config?.transcriptionLanguage ?? DEFAULT_TRANSCRIPTION_LANGUAGE;
576
+
577
+    if (transcriptionLanguage !== DEFAULT_TRANSCRIPTION_LANGUAGE) {
578
+        this.setTranscriptionLanguage(transcriptionLanguage);
572 579
     }
573 580
 };
574 581
 
@@ -2668,7 +2675,20 @@ JitsiConference.prototype.setLocalParticipantProperty = function(name, value) {
2668 2675
  */
2669 2676
 JitsiConference.prototype.removeLocalParticipantProperty = function(name) {
2670 2677
     this.removeCommand(`jitsi_participant_${name}`);
2671
-    this.room.sendPresence();
2678
+    if (this.room) {
2679
+        this.room.sendPresence();
2680
+    }
2681
+};
2682
+
2683
+/**
2684
+ * Sets the transcription language.
2685
+ * NB: Unlike _init_ here we don't check for the default value since we want to allow
2686
+ * the value to be reset.
2687
+ *
2688
+ * @param lang the new transcription language to be used.
2689
+ */
2690
+JitsiConference.prototype.setTranscriptionLanguage = function(lang) {
2691
+    this.setLocalParticipantProperty('transcription_language', lang);
2672 2692
 };
2673 2693
 
2674 2694
 /**

Загрузка…
Отмена
Сохранить