Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(conference) add ability to change the transcription language #2600

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const logger = getLogger(__filename);
*/
const JINGLE_SI_TIMEOUT = 5000;

/**
* Default source language for transcribing the local participant.
*/
const DEFAULT_TRANSCRIPTION_LANGUAGE = 'en-US';

/**
* Checks if a given string is a valid video codec mime type.
*
Expand Down Expand Up @@ -567,8 +572,10 @@ JitsiConference.prototype._init = function(options = {}) {
// In case the language config is undefined or has the default value that the transcriber uses
// (in our case Jigasi uses 'en-US'), don't set the participant property in order to avoid
// needlessly polluting the presence stanza.
if (config && config.transcriptionLanguage && config.transcriptionLanguage !== 'en-US') {
this.setLocalParticipantProperty('transcription_language', config.transcriptionLanguage);
const transcriptionLanguage = config?.transcriptionLanguage ?? DEFAULT_TRANSCRIPTION_LANGUAGE;

if (transcriptionLanguage !== DEFAULT_TRANSCRIPTION_LANGUAGE) {
this.setTranscriptionLanguage(transcriptionLanguage);
}
};

Expand Down Expand Up @@ -2668,7 +2675,20 @@ JitsiConference.prototype.setLocalParticipantProperty = function(name, value) {
*/
JitsiConference.prototype.removeLocalParticipantProperty = function(name) {
this.removeCommand(`jitsi_participant_${name}`);
this.room.sendPresence();
if (this.room) {
this.room.sendPresence();
}
};

/**
* Sets the transcription language.
* NB: Unlike _init_ here we don't check for the default value since we want to allow
* the value to be reset.
*
* @param lang the new transcription language to be used.
*/
JitsiConference.prototype.setTranscriptionLanguage = function(lang) {
this.setLocalParticipantProperty('transcription_language', lang);
};

/**
Expand Down