File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,12 @@ export function whisper_language_to_code(language) {
135135 if ( language_code === undefined ) {
136136 // User provided something that is not a language name
137137
138+ // Perhaps the user passed the special token itself
139+ const language_special_token = language . match ( / ^ < \| ( [ a - z ] { 2 } ) \| > $ / ) ;
140+ if ( language_special_token ) {
141+ language = language_special_token [ 1 ] ;
142+ }
143+
138144 if ( WHISPER_LANGUAGE_MAPPING . has ( language ) ) {
139145 // User provided the language code directly (e.g., "en")
140146 language_code = language ;
@@ -144,7 +150,7 @@ export function whisper_language_to_code(language) {
144150 const is_language_code = language . length === 2 ;
145151 const langs = is_language_code ? WHISPER_LANGUAGE_MAPPING . keys ( ) : WHISPER_LANGUAGE_MAPPING . values ( ) ;
146152
147- throw new Error ( `Language "${ language } " is not supported. Must be one of: ${ JSON . stringify ( langs ) } ` ) ;
153+ throw new Error ( `Language "${ language } " is not supported. Must be one of: ${ JSON . stringify ( Array . from ( langs ) ) } ` ) ;
148154 }
149155 }
150156 return language_code ;
You can’t perform that action at this time.
0 commit comments