whisper : adding <stddef.h> needed for size_t + code style

pull/353/head
Georgi Gerganov 3 years ago
parent 48389940be
commit 06130452b6
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

@ -463,7 +463,7 @@ static bool whisper_model_load(struct whisper_model_loader * loader, whisper_con
uint32_t magic;
read_safe(loader, magic);
if (magic != 0x67676d6c) {
fprintf(stderr, "%s: invalid model file (bad magic)\n", __func__);
fprintf(stderr, "%s: invalid model data (bad magic)\n", __func__);
return false;
}
}
@ -2276,6 +2276,7 @@ struct whisper_context * whisper_init_from_buffer(void * buffer, size_t buffer_s
fprintf(stderr, "%s: loading model from buffer\n", __func__);
loader.context = &ctx;
loader.read = [](void * ctx, void * output, size_t read_size) {
buf_context * buf = reinterpret_cast<buf_context *>(ctx);
@ -2293,7 +2294,7 @@ struct whisper_context * whisper_init_from_buffer(void * buffer, size_t buffer_s
return buf->current_offset >= buf->size;
};
loader.close = [](void * ctx) { };
loader.close = [](void * /*ctx*/) { };
return whisper_init(&loader);
}
@ -2315,6 +2316,7 @@ struct whisper_context * whisper_init(struct whisper_model_loader * loader) {
}
ctx->t_load_us = ggml_time_us() - t_start_us;
loader->close(loader->context);
return ctx;

@ -1,6 +1,7 @@
#ifndef WHISPER_H
#define WHISPER_H
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
@ -92,8 +93,9 @@ extern "C" {
void (*close)(void * ctx);
} whisper_model_loader;
// Allocates all memory needed for the model and loads the model from the given file.
// Returns NULL on failure.
// Various function to load a ggml whisper model.
// Allocates (almost) all memory needed for the model.
// Return NULL on failure
WHISPER_API struct whisper_context * whisper_init_from_file(const char * path_model);
WHISPER_API struct whisper_context * whisper_init_from_buffer(void * buffer, size_t buffer_size);
WHISPER_API struct whisper_context * whisper_init(struct whisper_model_loader * loader);

Loading…
Cancel
Save