Skip to content

How can I keep the Whisper model loaded in memory across multiple transcriptions, instead of reloading it for each audio file? #3309

Answered by officiallyutso
YuXing404 asked this question in Q&A
Discussion options

You must be logged in to vote

You can load the model once using whisper_init_from_file() and reuse the returned whisper_context pointer across multiple calls to whisper_full().

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 whisper_full_params is reset appropriately for each run. Also, avoid sharing the same ctx between threads unless protected.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuXing404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants