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

fix: transcript results from whisper may have json.language="zh-TW" a… #15338

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
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
13 changes: 12 additions & 1 deletion react/features/subtitles/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
// Regex to filter out all possible country codes after language code:
// this should catch all notations like 'en-GB' 'en_GB' and 'enGB'
// and be independent of the country code length
if (json.language.replace(/[-_A-Z].*/, '') !== language) {
if (_getPrimaryLanguageCode(json.language) !== _getPrimaryLanguageCode(language)) {
return next(action);
}

Expand Down Expand Up @@ -260,6 +260,17 @@
return next(action);
}

/**
* Utility function to extract the primary language code like 'en-GB' 'en_GB'

Check warning on line 264 in react/features/subtitles/middleware.ts

View workflow job for this annotation

GitHub Actions / Lint

Sentences must end with a period

Check failure on line 264 in react/features/subtitles/middleware.ts

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
* 'enGB' 'zh-CN' and 'zh-TW'
*

Check failure on line 266 in react/features/subtitles/middleware.ts

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
* @param {string} language The language to use for translation or user requested

Check failure on line 267 in react/features/subtitles/middleware.ts

View workflow job for this annotation

GitHub Actions / Lint

There must be a hyphen before @param description
* @returns {string}
*/
function _getPrimaryLanguageCode(language: string) {
return language.replace(/[-_A-Z].*/, '');
}

/**
* Toggle the local property 'requestingTranscription'. This will cause Jicofo
* and Jigasi to decide whether the transcriber needs to be in the room.
Expand Down
Loading