@@ -3032,7 +3032,14 @@ int whisper_ctx_init_openvino_encoder(
3032
3032
#endif
3033
3033
}
3034
3034
3035
- struct whisper_context * whisper_init_from_file_no_state (const char * path_model, whisper_context_params params) {
3035
+ struct whisper_context_params whisper_context_default_params () {
3036
+ struct whisper_context_params result = {
3037
+ /* .use_gpu =*/ true ,
3038
+ };
3039
+ return result;
3040
+ }
3041
+
3042
+ struct whisper_context * whisper_init_from_file_with_params_no_state (const char * path_model, struct whisper_context_params params) {
3036
3043
log (" %s: loading model from '%s'\n " , __func__, path_model);
3037
3044
3038
3045
auto fin = std::ifstream (path_model, std::ios::binary);
@@ -3061,7 +3068,7 @@ struct whisper_context * whisper_init_from_file_no_state(const char * path_model
3061
3068
fin->close ();
3062
3069
};
3063
3070
3064
- auto ctx = whisper_init_no_state (&loader, params);
3071
+ auto ctx = whisper_init_with_params_no_state (&loader, params);
3065
3072
3066
3073
if (ctx) {
3067
3074
ctx->path_model = path_model;
@@ -3070,7 +3077,7 @@ struct whisper_context * whisper_init_from_file_no_state(const char * path_model
3070
3077
return ctx;
3071
3078
}
3072
3079
3073
- struct whisper_context * whisper_init_from_buffer_no_state (void * buffer, size_t buffer_size, whisper_context_params params) {
3080
+ struct whisper_context * whisper_init_from_buffer_with_params_no_state (void * buffer, size_t buffer_size, struct whisper_context_params params) {
3074
3081
struct buf_context {
3075
3082
uint8_t * buffer;
3076
3083
size_t size;
@@ -3104,10 +3111,10 @@ struct whisper_context * whisper_init_from_buffer_no_state(void * buffer, size_t
3104
3111
3105
3112
loader.close = [](void * /* ctx*/ ) { };
3106
3113
3107
- return whisper_init_no_state (&loader, params);
3114
+ return whisper_init_with_params_no_state (&loader, params);
3108
3115
}
3109
3116
3110
- struct whisper_context * whisper_init_no_state (struct whisper_model_loader * loader, whisper_context_params params) {
3117
+ struct whisper_context * whisper_init_with_params_no_state (struct whisper_model_loader * loader, struct whisper_context_params params) {
3111
3118
ggml_time_init ();
3112
3119
3113
3120
whisper_context * ctx = new whisper_context;
@@ -3125,8 +3132,8 @@ struct whisper_context * whisper_init_no_state(struct whisper_model_loader * loa
3125
3132
return ctx;
3126
3133
}
3127
3134
3128
- struct whisper_context * whisper_init_from_file (const char * path_model, whisper_context_params params) {
3129
- whisper_context * ctx = whisper_init_from_file_no_state (path_model, params);
3135
+ struct whisper_context * whisper_init_from_file_with_params (const char * path_model, struct whisper_context_params params) {
3136
+ whisper_context * ctx = whisper_init_from_file_with_params_no_state (path_model, params);
3130
3137
if (!ctx) {
3131
3138
return nullptr ;
3132
3139
}
@@ -3140,8 +3147,8 @@ struct whisper_context * whisper_init_from_file(const char * path_model, whisper
3140
3147
return ctx;
3141
3148
}
3142
3149
3143
- struct whisper_context * whisper_init_from_buffer (void * buffer, size_t buffer_size, whisper_context_params params) {
3144
- whisper_context * ctx = whisper_init_from_buffer_no_state (buffer, buffer_size, params);
3150
+ struct whisper_context * whisper_init_from_buffer_with_params (void * buffer, size_t buffer_size, struct whisper_context_params params) {
3151
+ whisper_context * ctx = whisper_init_from_buffer_with_params_no_state (buffer, buffer_size, params);
3145
3152
if (!ctx) {
3146
3153
return nullptr ;
3147
3154
}
@@ -3155,8 +3162,8 @@ struct whisper_context * whisper_init_from_buffer(void * buffer, size_t buffer_s
3155
3162
return ctx;
3156
3163
}
3157
3164
3158
- struct whisper_context * whisper_init (struct whisper_model_loader * loader, whisper_context_params params) {
3159
- whisper_context * ctx = whisper_init_no_state (loader, params);
3165
+ struct whisper_context * whisper_init_with_params (struct whisper_model_loader * loader, struct whisper_context_params params) {
3166
+ whisper_context * ctx = whisper_init_with_params_no_state (loader, params);
3160
3167
if (!ctx) {
3161
3168
return nullptr ;
3162
3169
}
@@ -3170,6 +3177,30 @@ struct whisper_context * whisper_init(struct whisper_model_loader * loader, whis
3170
3177
return ctx;
3171
3178
}
3172
3179
3180
+ struct whisper_context * whisper_init_from_file (const char * path_model) {
3181
+ return whisper_init_from_file_with_params (path_model, whisper_context_default_params ());
3182
+ }
3183
+
3184
+ struct whisper_context * whisper_init_from_buffer (void * buffer, size_t buffer_size) {
3185
+ return whisper_init_from_buffer_with_params (buffer, buffer_size, whisper_context_default_params ());
3186
+ }
3187
+
3188
+ struct whisper_context * whisper_init (struct whisper_model_loader * loader) {
3189
+ return whisper_init_with_params (loader, whisper_context_default_params ());
3190
+ }
3191
+
3192
+ struct whisper_context * whisper_init_from_file_no_state (const char * path_model) {
3193
+ return whisper_init_from_file_with_params_no_state (path_model, whisper_context_default_params ());
3194
+ }
3195
+
3196
+ struct whisper_context * whisper_init_from_buffer_no_state (void * buffer, size_t buffer_size) {
3197
+ return whisper_init_from_buffer_with_params_no_state (buffer, buffer_size, whisper_context_default_params ());
3198
+ }
3199
+
3200
+ struct whisper_context * whisper_init_no_state (struct whisper_model_loader * loader) {
3201
+ return whisper_init_with_params_no_state (loader, whisper_context_default_params ());
3202
+ }
3203
+
3173
3204
void whisper_free_state (struct whisper_state * state)
3174
3205
{
3175
3206
if (state) {
0 commit comments