Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
fix: offer the full Whisper language set in ASR language dropdowns via Intl.DisplayNames (#359)
Murtaza Nasir27e1ea91ccd7
diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex 605d4d2d..41ad784f 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -2693,22 +2693,53 @@ document.addEventListener('DOMContentLoaded', async () => {];});- // Language options for ASR+ // Language options for ASR: the full Whisper language set (the+ // old hardcoded 11-language list locked out every other+ // supported language, issue #359). Labels come from+ // Intl.DisplayNames so they render localized without needing+ // translation keys for ~100 languages.+ const WHISPER_LANGUAGE_CODES = [+ 'en', 'zh', 'de', 'es', 'ru', 'ko', 'fr', 'ja', 'pt', 'tr', 'pl', 'ca',+ 'nl', 'ar', 'sv', 'it', 'id', 'hi', 'fi', 'vi', 'he', 'uk', 'el', 'ms',+ 'cs', 'ro', 'da', 'hu', 'ta', 'no', 'th', 'ur', 'hr', 'bg', 'lt', 'la',+ 'mi', 'ml', 'cy', 'sk', 'te', 'fa', 'lv', 'bn', 'sr', 'az', 'sl', 'kn',+ 'et', 'mk', 'br', 'eu', 'is', 'hy', 'ne', 'mn', 'bs', 'kk', 'sq', 'sw',+ 'gl', 'mr', 'pa', 'si', 'km', 'sn', 'yo', 'so', 'af', 'oc', 'ka', 'be',+ 'tg', 'sd', 'gu', 'am', 'yi', 'lo', 'uz', 'fo', 'ht', 'ps', 'tk', 'nn',+ 'mt', 'sa', 'lb', 'my', 'bo', 'tl', 'mg', 'as', 'tt', 'haw', 'ln', 'ha',+ 'ba', 'jw', 'su', 'yue'+ ];+ // Codes Intl.DisplayNames can't resolve (or resolves under a+ // different ISO tag than Whisper uses).+ const WHISPER_LANGUAGE_LABEL_OVERRIDES = {+ jw: 'jv', // Whisper uses 'jw' for Javanese (ISO is 'jv')+ };+ const WHISPER_LANGUAGE_FALLBACK_NAMES = {+ haw: 'Hawaiian',+ yue: 'Cantonese',+ };const languageOptions = computed(() => {- return [- { value: '', label: t('form.autoDetect') },- { value: 'en', label: t('languages.en') },- { value: 'es', label: t('languages.es') },- { value: 'fr', label: t('languages.fr') },- { value: 'de', label: t('languages.de') },- { value: 'it', label: t('languages.it') },- { value: 'pt', label: t('languages.pt') },- { value: 'nl', label: t('languages.nl') },- { value: 'ru', label: t('languages.ru') },- { value: 'zh', label: t('languages.zh') },- { value: 'ja', label: t('languages.ja') },- { value: 'ko', label: t('languages.ko') }- ];+ const uiLocale = (window.i18n && window.i18n.currentLocale) || 'en';+ let displayNames = null;+ try {+ displayNames = new Intl.DisplayNames([uiLocale, 'en'], { type: 'language' });+ } catch (e) { /* very old browsers: fall back to raw codes */ }+ const options = WHISPER_LANGUAGE_CODES.map(code => {+ const lookup = WHISPER_LANGUAGE_LABEL_OVERRIDES[code] || code;+ let label = null;+ if (displayNames) {+ try {+ const name = displayNames.of(lookup);+ // DisplayNames echoes back unknown codes; treat that as a miss+ if (name && name !== lookup) label = name;+ } catch (e) { /* invalid tag for this engine */ }+ }+ if (!label) label = WHISPER_LANGUAGE_FALLBACK_NAMES[code] || code;+ label = label.charAt(0).toLocaleUpperCase(uiLocale) + label.slice(1);+ return { value: code, label };+ });+ options.sort((a, b) => a.label.localeCompare(b.label, uiLocale));+ return [{ value: '', label: t('form.autoDetect') }, ...options];});// Recording metadata for sidebar