Skip to content

Commit cdd4e4e

Browse files
committed
whisper.wasm : fix unknown language issue
TODO: Refs: TODO:
1 parent eac1bc9 commit cdd4e4e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/whisper.wasm/emscripten.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ EMSCRIPTEN_BINDINGS(whisper) {
7171
params.print_timestamps = true;
7272
params.print_special = false;
7373
params.translate = translate;
74-
params.language = whisper_is_multilingual(g_contexts[index]) ? lang.c_str() : "en";
74+
params.language = whisper_is_multilingual(g_contexts[index]) ? strdup(lang.c_str()) : "en";
7575
params.n_threads = std::min(nthreads, std::min(16, mpow2(std::thread::hardware_concurrency())));
7676
params.offset_ms = 0;
7777

@@ -106,6 +106,9 @@ EMSCRIPTEN_BINDINGS(whisper) {
106106
whisper_reset_timings(g_contexts[index]);
107107
whisper_full(g_contexts[index], params, pcmf32.data(), pcmf32.size());
108108
whisper_print_timings(g_contexts[index]);
109+
if (params.language != nullptr && strcmp(params.language, "en") != 0) {
110+
free((void*)params.language);
111+
}
109112
});
110113
}
111114

0 commit comments

Comments
 (0)