How can I keep the Whisper model loaded in memory across multiple transcriptions, instead of reloading it for each audio file? #3309
-
I’m building a tool that needs to transcribe multiple audio files one after another. What’s the recommended way to keep the Whisper model loaded in memory across multiple transcriptions, so I don’t have to reload it from disk each time? |
Beta Was this translation helpful? Give feedback.
Answered by
officiallyutso
Jul 8, 2025
Replies: 1 comment
-
You can load the model once using struct whisper_context *ctx = whisper_init_from_file("models/ggml-base.en.bin");
// Reuse `ctx` for multiple audio files
whisper_full(ctx, params, audio1);
whisper_full(ctx, params, audio2);
// ...
whisper_free(ctx); Just make sure your |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
YuXing404
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can load the model once using
whisper_init_from_file()
and reuse the returnedwhisper_context
pointer across multiple calls towhisper_full()
.Just make sure your
whisper_full_params
is reset appropriately for each run. Also, avoid sharing the samectx
between threads unless protected.