mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-05-29 22:18:54 +02:00
whisper.wasm : fix unknown language issue (#3000)
* whisper.wasm : fix unknown language issue This commit addresses an issue with whisper.wasm where the following error was being displayed when running the application in github pages: ``` whisper_lang_id: unknown language 'д=␙c' ``` This turned out to be a memory corruption issue and further details can be found in the reference issue below. Refs: https://github.com/ggerganov/whisper.cpp/issues/2998
This commit is contained in:
parent
eac1bc9c47
commit
77e0c86ab6
@ -65,13 +65,14 @@ EMSCRIPTEN_BINDINGS(whisper) {
|
||||
}
|
||||
|
||||
struct whisper_full_params params = whisper_full_default_params(whisper_sampling_strategy::WHISPER_SAMPLING_GREEDY);
|
||||
bool is_multilingual = whisper_is_multilingual(g_contexts[index]);
|
||||
|
||||
params.print_realtime = true;
|
||||
params.print_progress = false;
|
||||
params.print_timestamps = true;
|
||||
params.print_special = false;
|
||||
params.translate = translate;
|
||||
params.language = whisper_is_multilingual(g_contexts[index]) ? lang.c_str() : "en";
|
||||
params.language = is_multilingual ? strdup(lang.c_str()) : "en";
|
||||
params.n_threads = std::min(nthreads, std::min(16, mpow2(std::thread::hardware_concurrency())));
|
||||
params.offset_ms = 0;
|
||||
|
||||
@ -102,10 +103,13 @@ EMSCRIPTEN_BINDINGS(whisper) {
|
||||
|
||||
// run the worker
|
||||
{
|
||||
g_worker = std::thread([index, params, pcmf32 = std::move(pcmf32)]() {
|
||||
g_worker = std::thread([index, params, pcmf32 = std::move(pcmf32), is_multilingual]() {
|
||||
whisper_reset_timings(g_contexts[index]);
|
||||
whisper_full(g_contexts[index], params, pcmf32.data(), pcmf32.size());
|
||||
whisper_print_timings(g_contexts[index]);
|
||||
if (is_multilingual) {
|
||||
free((void*)params.language);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user